Selected text

February 27th, 2010

Zeldman pointed out a nice CSS3 feature. To set the colour of selected text, try adding this to your style sheet:

::-moz-selection { color: #004080; background: #fffdd7; }
::selection { color: #004080; background: #fffdd7; }

To my knowledge, this feature works in Mozilla-based browsers, Safari and Opera.1 It doesn't work in Internet Explorer, but it doesn't break anything either.

  1. I wouldn't know about Chrome. Google – like quite a few suppliers of Mac OS X software nowadays – don't bother producing a version of their browser for PowerPC-based Macs. However, I'd be very surprised if this feature isn't supported in Chrome, given that it uses the same Webkit rendering engine as Safari.

Tags for this entry , ,

This entry was posted on Saturday, February 27th, 2010 at 23:14. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.