How to disable text selection highlighting in the browsers using CSS
Topic: HTML / CSSPrev|Next
Answer: Use the CSS ::selection
pseudo-element
By default, when you select some text in the browsers it is highlighted normally in blue color. But, you can disable this highlighting with the CSS ::selection
pseudo-element.
Currently browsers only support a small subset of CSS properties for ::selection
pseudo-element like color
, background-color
and text-shadow
. Here's an example:
Example
Try this code »::selection {
color: none;
background: none;
}
/* For Mozilla Firefox */
::-moz-selection {
color: none;
background: none;
}
Related FAQ
Here are some more FAQ related to this topic: