Open In App
Related Articles

CSS ::selection Selector

Improve Article
Save Article
Like Article

The selection selector is used to set 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 is used with ::selection selector. Supported CSS properties are color, background, cursor, and outline. 


::selection {
    // CSS Property



<!DOCTYPE html>
    <title>::selection Selector</title>
        h1 {
            color: green;
        body {
            text-align: center;
        /* CSS property for Firefox */
        ::-moz-selection {
            color: white;
            background: green;
        ::selection {
            color: white;
            background: green;
    <h2>::selection selector</h2>
    <p>A Computer Science portal for geeks </p>



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

  • Apple Safari 1.1 and above
  • Google Chrome 1.0 and above
  • Edge 12.0 and above
  • Firefox 62.0 and above
  • Opera 9.5 and above
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 : 05 Jul, 2023
Like Article
Save Article
Similar Reads
Related Tutorials