Making text unselectable
Making text unselectable
185
27-Apr-2023
Updated on 27-Apr-2023
Aryan Kumar
27-Apr-2023To make text unselectable on an HTML page, you can use the user-select CSS property. Here's an example:
In this example, any element with the class unselectable will not be selectable by the user. This is particularly useful when you want to prevent users from copying or highlighting certain parts of the text, such as copyright notices or disclaimers.
Note that the user-select property is not supported in all browsers, particularly older versions of Internet Explorer. If you need to ensure cross-browser compatibility, you may want to use JavaScript instead to prevent text selection.