1

How to change the colour of text when its selected by css/javascript? A cross browser compatible solution would be preferred.

Thanks in advance.

gopi1410
  • 6,567
  • 9
  • 41
  • 75
  • @sp00m: may I point you to a meta question dealing with 'let me Google that for you' links: http://meta.stackexchange.com/questions/15650/ban-lmgtfy-let-me-google-that-for-you-links – David Thomas Apr 20 '12 at 12:03
  • Ah, sorry, I didn't know... I just think he is the 1 000 000 th guy who wanna change the color of a selected text. But OK, I'll never do it again :) – sp00m Apr 20 '12 at 12:09

1 Answers1

4

just use ::selection in your stylesheet. you can view an example on quirksmode.org. as you can read here, this is supported by all modern browsers except internet explorer <9.

oezi
  • 51,017
  • 10
  • 98
  • 115