CSS User Select

Whilst working on a project today, I came across this useful CSS property. Although not currently a standard it is useable across most of the new browsers.

By applying user select of none to a Class or ID, you can prevent the default ability to highlight. This could be really useful for a blog where you don’t want someone to be able to copy and paste your snippet, or a learning resource where you want the students to do the work for themselves without being able to copy and paste. Whilst this can be used to prevent copy, it’s not bullet proof as the user can disable the property in inspect element. For a more solid and rigid solution to prevent the use of copy, a JavaScript implementation should be considered.

The use of this CSS property today was to prevent a CSS Button from being highlighted when being pressed. The button was using a jQuery event listener and not < a > links, hence the need to prevent the clicks from allowing the object to be highlighted.


-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: moz-none;
-ms-user-select: none;
user-select: none;