::selection CSS Pseudo Element
Description
The ::selection
pseudo-element applies style to the text selected by the user. The following properties are allowed in style rules: color, background, background-color, cursor, outline and text-shadow .
Syntax
element::selection { … }
Example
<p class="select">Select this text with your mouse to view the effect of the ::selection pseudo-element.</p>
<p>Now select this text to see how it would normally look.</p>
p.select::selection {
color: #ff0;
background: #000;
}
Notes
Firefox prior to version 62 uses the non-standard pseudo-element ::-moz-selection.
Browser Support
Desktop | |||||
9 | 12 | 1 | 62 | 9.5 | 1.1 |
Tablets / Mobile | |||||
![]() |
|||||
37 | 18 | 62 | X | 1 | X |
Last updated by CSSPortal on: 25th November 2019
CSS Pseudo Elements
CSS Pseudo Classes
- :active
- :checked
- :default
- :disabled
- :empty
- :enabled
- :first-child
- :first-of-type
- :focus
- :fullscreen
- :hover
- :in-range
- :indeterminate
- :invalid
- :lang
- :last-child
- :last-of-type
- :link
- :not
- :nth-child
- :nth-last-child
- :nth-last-of-type
- :nth-of-type
- :only-child
- :only-of-type
- :optional
- :out-of-range
- :read-only
- :read-write
- :required
- :root
- :target
- :valid
- :visited