Log in

View Full Version : Text selection - change color - how to?



me_myself
11-13-2008, 06:00 PM
I recently saw a css website where if you select the text, the selection just changes color instead of the blue highlight which normal websites do. I was wondering how to achieve this? Any help would be greatly appreciated :)

Schmoopy
11-13-2008, 06:28 PM
Here's how to achieve what you want, only works in Firefox / Safari (I think, not 100%)

put this in your CSS:


::selection {
background: #FF99CC;
}
::-moz-selection {
background: #FF99CC;
}

So let's say you have a class called "content", it would look like this:



.content::selection{
background: #FF99CC;
}
.content::-moz-selection{ /* For Firefox */
background: #FF99CC;
}


Good luck with it :)

Snookerman
11-17-2008, 09:27 PM
only works in Firefox / Safari (I think, not 100%)
Works in FF3 and Opera 9.6 but not in IE6 or IE7. Safari I don't know. Does anyone know how to make it work in IE?
OP, what browser did you view that website in? Do you have the link to the site?

Arctic Fox
03-25-2013, 05:16 AM
Bump'n the thread after doing a search. I found this fascinating and have it coded on my site now. Fairly useless other than a customizing point.

http://arctic.ithium.net/