Customize background and text color when text is selected.
Select any text below to see the custom selection style in action.
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.
The ::selection CSS pseudo-element controls how selected/highlighted text appears on your page.
color β Selected text colorbackground β Selected text background colortext-shadow β Text shadow (limited browser support)::selection works in IE9+ and all modern browsers. Firefox v62+ uses the unprefixed version (use ::-moz-selection for older versions).