Can I do away with this highlighting in HTML?
Whenever we select so开发者_开发技巧me text, the entire text area gets highligted. like this .
but is there any way to do away with this highlighting? I want just the color of the text to change and not the area to be highlighted as it appears in the image? am I clear enough?
Depends on which browsers you need to support. Not sure if Internet Explorer does support it, but here are the three CSS pseudo-elements you can try:
::selection (works in my Chrome)
::-moz-selection
::-webkit-selection
For example:
p::selection {
background:#cc0000;
color:#fff;
}
Also see http://www.quirksmode.org/css/selection.html
If you're talking about when someone selects the text in the browser (using the mouse or shift-selecting) then this isn't possible.
[UPDATE]
I take it all back - as @Dev F and @nico say, there's a selection CSS3 property. (Of course only some browsers will support this, but...)
精彩评论