CSS ::selection Selector
Example
Make the selected text red on a yellow background:
::selection
{
color: red;
background: yellow;
}
Try it Yourself »
Definition and Usage
The ::selection
selector matches the portion of an element that is selected by a user.
Only a few CSS properties can be applied to the ::selection selector: color, background, cursor, and outline.
Browser Support
The numbers in the table specify the first browser version that fully supports the property.
Numbers followed by -webkit- or -moz- specify the first version that worked with a prefix.
Selector | |||||
---|---|---|---|---|---|
::selection | 4.0 | 9.0 | 62.0 2.0 -moz- |
3.1 | 10.1 |
CSS Syntax
::selection {
css declarations;
}
Copyright 1999-2023 by Refsnes Data. All Rights Reserved.