Read more

CSS: Change text selection color

Arne Hartherz
February 20, 2012Software engineer at makandra GmbH

You can change the color for text selection via CSS, using the ::selection and ::-moz-selection pseudo-elements.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

Adding this to your Sass will make all text selections use a red background:

::selection
  background-color: #f00

::-moz-selection
  background-color: #f00

Unfortunately, those can't be combined into "::selection, ::-moz-selection". Doing so will have no effect.

Posted by Arne Hartherz to makandra dev (2012-02-20 11:07)