tags:

views:

30

answers:

2

I mean: when you select some html text there's a color in the background wich tells you wich text you've selected, how is it possible thru css to change it, i need it to be white , transparent. i' have seen this done. cheers

+1  A: 

You can't change that with CSS. It's a browser/OS specific behavior.

You might get away with using some JS hack, but I wouldn't do it.

NullUserException
A: 

You can use certain CSS selectors to change CSS properties on selected text. (I tested this and it worked in Firefox, Safari, Chrome, and even Konqueror, but not IE). Example:

*::selection {
    background: #cc0000;
    color: #ffffff;
}
*::-moz-selection {
    background: #cc0000;
    color: #ffffff;
}
*::-webkit-selection {
    background: #cc0000;
    color: #ffffff;
}

You have to specify each selector separately or else it doesn't work (I guess the CSS parser stops processing a selector if it encounters an error). This changes the background color of the selected text to dark red and the color to white (and any other CSS you want to change). This doesn't have great cross-browser support (doesn't work in IE, and probably not Opera, either), but I think it is the only solution possible without some kind of complicated, buggy JavaScript script.

More info: http://www.quirksmode.org/css/selection.html

jake33
Thanks a lot Jake33.
tada