Skip to main content

Disabling User text selection with css

Today, while working on an interactive kiosk, I needed to disable the text selection highlighting. After a few searches I discovered this was possible using CSS.

The code is:

  1. *{
  2.   -webkit-touch-callout: none;
  3.   -webkit-user-select: none;
  4.   -khtml-user-select: none;
  5.   -moz-user-select: none;
  6.   -ms-user-select: none;
  7.   user-select: none;
  8. }

The above will remove the highlighting from selected text, but will not prevent text selections.