To make text unselectable on an HTML page, you can use the user-select CSS property. Here's an example:
.unselectable {
user-select: none;
}
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.
Markdown for AI
A clean, structured version of this page for AI assistants and LLMs.
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy.
To 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.