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 web development

Do you need DevOps-experts?

Your development team has a full backlog? No time for infrastructure architecture? Our DevOps team is ready to support you!

  • We build reliable cloud solutions with Infrastructure as code
  • We are experts in security, Linux and databases
  • We support your dev team to perform
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)