CSS Option 1
The following CSS code covers disabling text selection on all major browsers:
The following code will be used to place text within the area that can be selected and highlight, as well as the area where the text cannot be selected and highlighted.
Almost all browsers are supported by user-select, except for Internet Explorer 9 and earlier. However, as this is not a standard feature, there could be problems in implementing the code in different browsers.
CSS Option 2
An alternative CSS approach using a div container would use the following code:
Place the text that must not be selectable and highlighted within the following div tags:
Since this property is not inheritable, the tag will have to be applied for every element within the div container.
When would you do this?
Many webmasters opt for disabling the text selection and highlighting feature to prevent unauthorized copying of content from their website. However, there is no foolproof way to disable the text selection entirely. Disabling text selection may work for the amateur content scrapers but does not prevent copying the HTML and automated copy scraping programs. Therefore it is of limited benefit for the intended purpose.