CSS ::selection Pseudo-element

Definition and Usage

CSS ::selection Pseudo-elements are used to set the style of the selected text part of the user.

Note:The following properties can be used with ::selection Used together:

  • color
  • background-color
  • text-decoration
  • text-shadow

Example

Set the text color to red and the background to yellow for the selected text of the user:

::selection {
  color: red;
  background: yellow;
}

Try It Yourself

CSS Syntax

::selection {
  css declarations;
}

Technical Details

Version: CSS3

Browser Support

The numbers in the table specify the first browser version that fully supports the pseudo-element.

Chrome Edge Firefox Safari Opera
4 12 62 1.1 9.5