I need to disable the highlighting of selected text on my web app. I have a good reason for doing this and know that this is generally a bad idea. But I need to do it anyway. It doesn't matter if I need to use CSS or JS to do it. What I'm mainly going for is the removal of the blue color given to highlighted elements.
To disable text selection highlighting in Google Chrome browser using CSS just set -user-select CSS property to none. And no prefix is required for Google Chrome and Opera Browsers.
Select the text that you want to remove highlighting from, or press Ctrl+A to select all of the text. Go to Home and select the arrow next to Text Highlight Color. Select No Color.
Use the user-select: none; CSS rule.
You can use the user-select property to disable text selection of an element. In web browsers, if you double-click on some text it will be selected/highlighted. This property can be used to prevent this.
You can use the CSS pseudo class selector ::selection
and ::-moz-selection
for Firefox.
For example:
::-moz-selection { background-color: transparent; color: #000; } ::selection { background-color: transparent; color: #000; } .myclass::-moz-selection, .myclass::selection { ... }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With