10

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: https://i.stack.imgur.com/3OKaP.png)

krasatos
  • 1,177
  • 3
  • 13
  • 26

7 Answers7

16

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>
Tarun Kumar
  • 508
  • 3
  • 14
12

Useoutline:none or outline:0

Check the similar one here

Community
  • 1
  • 1
Sowmya
  • 26,684
  • 21
  • 96
  • 136
3

this worked in my case:

element {

-webkit-tap-highlight-color: transparent;

}

as per Mozilla Docs

philipeachille
  • 185
  • 1
  • 6
2

Add outline:0; to your div.

I usually see this problem on IE more than other browsers.

Ref here for more info:

Andrea Ligios
  • 49,480
  • 26
  • 114
  • 243
Raphaël VO
  • 2,413
  • 4
  • 19
  • 32
0

Not sure if this is what you're looking for, but check Chris Coyers article (Removing The Dotted Outline) on this

But think about the usability issues if you don't set an alternative active state at all. But I guess Chris is mentioning this anyway.

escapedcat
  • 726
  • 10
  • 31
0
*:focus{outline:none}
  • please add this code in your css file. This is css issue
Saif Khan
  • 7
  • 3
0

Very important to add "a", to say you are adding it for a link:

<style>
.disableSelection a {
outline: 0;
}
</style>
Gediminas Šukys
  • 7,101
  • 7
  • 46
  • 59