CSS para impacientes

CSS como usar o Custom text selection

January 04, 2020

Changes the styling of text selection.

<p class="custom-text-selection">Select some of this text.</p>
::selection {
  background: aquamarine;
  color: black;
}
.custom-text-selection::selection {
  background: deeppink;
  color: white;
}

Explanation

  • ::selection defines a pseudo selector on an element to style text within it when selected. Note that if you don’t combine any other selector your style will be applied at document root level, to any selectable element.

Browser support

⚠️ Requires prefixes for full support and is not actually in any specification.

Acesse a Referência original