βοΈ ::selection Settings
Customize background and text color when text is selected.
ποΈ Live Preview
Select any text below to see the custom selection style in action.
π Select this text to see the effect
Drag your mouse to select this text β the background and text color will change to your configured values. This is the power of the CSS ::selection pseudo-element, giving you full control over how selected text appears on your website.
Well-designed selection styles enhance brand consistency and improve the reading experience. Many popular websites like Twitter and GitHub use custom selection styles.
π» CSS Code
π CSS ::selection Explained
The ::selection CSS pseudo-element controls how selected/highlighted text appears on your page.
Supported Properties
colorβ Selected text colorbackgroundβ Selected text background colortext-shadowβ Text shadow (limited browser support)
Design Tips
- Match selection background to your brand color
- Ensure sufficient contrast for readability
- Avoid overly bright selection backgrounds
- Use light selection in dark mode, dark selection in light mode
Browser Support
::selection works in IE9+ and all modern browsers. Firefox v62+ uses the unprefixed version (use ::-moz-selection for older versions).