How to make certain text not selectable with CSS
How to make certain text not selectable with CSS
29027-Apr-2023
Updated on 27-Apr-2023
Home / DeveloperSection / Forums / How to make certain text not selectable with CSS
How to make certain text not selectable with CSS
Aryan Kumar
27-Apr-2023To make certain text not selectable with CSS, you can use the user-select property with the value none. Here's an example:
In this example, any text within an element with the class not-selectable 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.