Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS3 ::selection selector

CSS3 ::selection selector

Complete CSS SelectorComplete CSS Selector Reference Manual

Example

Make the selected text red:

::selection

{

color:#ff0000;

}

::-moz-selection

{

color:#ff0000;

}

Try it »


Definition and Usage

::selection selector matches the portion of an element that is selected or highlighted by the user.

::selection can only be applied to a few CSS properties: color, background, cursor, and outline.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

IE9+, Opera, Google Chrome, and Safari support the ::selection selector.

Firefox supports it through its private property ::-moz-selection.


Complete CSS SelectorComplete CSS Selector Reference Manual