ashley sheridan.co.uk

Change Selected Text Colours

It can be frustrating sometimes to design a website, only to have the operating systm of a visitor change a bunch of the colours it uses for everything. One annoying example is the text selection colours. Thankfully, CSS can help with this, thanks to its ::selection selector.

  1. ::selection
  2. {
  3. }
  4.   background-color: #f00;
  5.   color: #fff;
  6. }
  7. ::-moz-selection
  8. {
  9. }
  10.   background-color: #f00;
  11.   color: #fff;
  12. }

Try it on this page to see what the end result is.