Custom text selection

CSS, Visual · Dec 30, 2020

Changes the styling of text selection.

  • Use the ::selection pseudo-selector to style text within it when selected.
Preview

Select some of this text.

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

.custom-text-selection::selection {
  background: deeppink;
  color: white;
}

More like this

  • Custom checkbox

    Creates a styled checkbox with animation on state change.

    CSS, Visual · Oct 11, 2021

  • Custom radio button

    Creates a styled radio button with animation on state change.

    CSS, Visual · Nov 16, 2022

  • Custom scrollbar

    Customizes the scrollbar style for elements with scrollable overflow.

    CSS, Visual · May 16, 2021