Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I do away with this highlighting in HTML?

Tags:

html

css

Whenever we select some 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?

like image 358
Sachindra Avatar asked Aug 06 '10 10:08

Sachindra


Video Answer


1 Answers

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

like image 200
Dev F Avatar answered Oct 21 '22 20:10

Dev F