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.
- 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. ↩