How to disable text selection highlighting in the browsers using CSS

Topic: HTML / CSS« Prev|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.

  • ::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:

 
Close

Your Feedback:

 

We would love to hear from you! Please say something.