dave dave - 10 months ago 42
CSS Question

How to stop highlighting of a div element when double-clicking

I have this div element with a background image and I want to stop highlighting on the div element when double-clicking it. Is there a CSS property for this?

Answer Source

The CSS below stops users from being able to select text. Live example: http://jsfiddle.net/hGTwu/20/

-webkit-user-select: none; /* Chrome/Safari */        
-moz-user-select: none; /* Firefox */
-ms-user-select: none; /* IE10+ */

/* Rules below not implemented in browsers yet */
-o-user-select: none;
user-select: none;

To target IE9 downwards and Opera the html attribute unselectable must be used instead:

<div unselectable="on">Test Text</div>
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download