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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)