You’re Unselectable

This block of code came across my Twitter timeline today framed as a CSS tip to prevent text selection on a web page:

html {
  user-select: none;

For funsies, I dropped that CSS on this very page you are reading (assuming you are reading it in the browser). It abuses user-select to prevent you from selecting the text.

The user-select property is not inheritable, despite the implication in the original tweet and how it may behave in Chrome and Safari (Can I Use does not note the open bugs, 761433 and 764316). Also, this property is not final and may change. Probably do not use it.

If you have draggable controls on your page and you find it annoying when its text content gets selected on drag, then only use this property after confirming users never need to select that text. Also, confirm that your draggable feature is also keyboard operable. If it does not work with a keyboard and/or it has no keyboard equivalent, you need to dump the feature. At which point this property will be mooted.

If, however, you are a Chrome/Safari user who has encountered this in the wild, I have a bookmarklet to re-enable text selection.

Copy or drag this link to your bookmarks: Re-enable Text Selection. Activating the link now should re-enable text selection on this page.

You should visit my bookmarklets page for others that can get you around some poor development practices.



In Safari, selection was initially not being prevented. DevTools told me user-select is an unsupported property and helpfully replaced it with -webkit-user-select.

It seems like a property that would be seldom useful. user-select: all could make it easier to select text that’s expected to be copied (serial number, confirmation code, etc.) but even that could be misused (“I don’t want my bad takes to be tweeted out of context so I’ll add user-select: all to all my posts”).

I didn’t need the video to get the page title’s reference but I appreciate it.

Curtis Wilcox; . Permalink
In response to Curtis Wilcox. Reply

I didn’t add the -webkit- or -ms- prefixed versions to the page or content because I don’t want them adopted. That being said, I updated the page so it should now block selection in Safari.

Adding the video was a nod to Steve Faulkner’s brief posts that often include referential music. I figured if it is in my head, I could stuff it on others’.

Leave a Comment or Response

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>