Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable DIV selection when clicking on it

Tags:

html

css

How can i avoid selecting a div and hide the highlight when i click in it?
I want to hide the dotted outline:
here's a screenshot if what i want to hide

(can't get the screenshot to appear, here it is: http://i.stack.imgur.com/3OKaP.png)

like image 258
krasatos Avatar asked Feb 26 '13 06:02

krasatos


3 Answers

it can be done with a css class . like .if this is your div :

<div class='disableSelection'>text</div>

then apply this css .

<style>
.disableSelection{
-webkit-touch-callout: none;
-webkit-user-select: none;
-khtml-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
outline: 0;
}
</style>
like image 58
Tarun Kumar Avatar answered Nov 09 '22 12:11

Tarun Kumar


this worked in my case:

element {

-webkit-tap-highlight-color: transparent;

}

as per Mozilla Docs

like image 41
philipeachille Avatar answered Nov 09 '22 11:11

philipeachille


Useoutline:none or outline:0

Check the similar one here

like image 12
Sowmya Avatar answered Nov 09 '22 13:11

Sowmya