CSS ::selection Pseudo-element
Example
Style the user-selected text with a red text color and a yellow background:
::selection
{
color: red;
background: yellow;
}
Try it Yourself »
Definition and Usage
The ::selection
pseudo-element is used to
style the part of a text that is selected by a user.
Note: The following properties can be used with ::selection:
- color
- background-color
- text-decoration
- text-shadow
Version: | CSS3 |
---|
Browser Support
The numbers in the table specify the first browser version that fully supports the pseudo-element.
Pseudo-element | |||||
---|---|---|---|---|---|
::selection | 4 | 12 | 62 | 1.1 | 9.5 |
CSS Syntax
::selection {
css declarations;
}