tags:

views:

81

answers:

4

how do i change the color of highlight/selection of text? the default is blue.

for example, if you highlight/select this text, it is blue; but on css-tricks.com if the text is highlight/select-ed, it is orange peach.

+1  A: 

with JS you checkout where the selection is. then you remove it and change the css background-color of the selected text part in to orange ;-)

helle
+1  A: 
::selection {
background: #ffb7b7; /* Safari */
}
::-moz-selection {
background: #ffb7b7; /* Firefox */
}

as it is explained in here:

http://css-tricks.com/overriding-the-default-text-selection-color-with-css/

FallenAngel
thank you very much!
fuz3d
+1  A: 

Why don't you read the css-tricks article on the subject: :-)

http://css-tricks.com/overriding-the-default-text-selection-color-with-css/

RoToRa
+1  A: 

It's a CSS3-only feature, that only Firefox and Safari have implemented so far (as far as I know).

::selection {
    background: #ffb7b7; /* Safari */
}
::-moz-selection {
    background: #ffb7b7; /* Firefox */
}
Andy
it works in opera as well.
fuz3d
Embarrassingly, I wrote that from Opera and I saw it working. Doh!
Andy