Open In App
Related Articles

How to change text selection color in the browsers using CSS ?

Improve Article
Save Article
Like Article

Most of the browsers by default highlight the selected text in a blue background. This can be changed by using the ::selection pseudo selector in CSS. 

The ::selectionselector is used for setting the CSS property to the part of the document that is selected by the user (such as clicking and dragging the mouse across text). Only some CSS properties are supported with this selector. These are color, background, cursor, and outline.


::selection {
    // Supported CSS Properties



<!DOCTYPE html>
        ::selection {
            color: red;
            background: violet;
            How to change the default text
            selection color in the browsers
            using CSS
<p> please select me </p>


Supported Browsers: The browser supported by the ::selection Selector are listed below:

  • Apple Safari 3.1
  • Google Chrome 4.0
  • Firefox 62.0 2.0-moz-
  • Opera 10.1
  • Internet Explorer 9.0
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 01 Jun, 2022
Like Article
Save Article
Similar Reads
Complete Tutorials