When we use Text Replacement using CSS and give a negative test-indent i.e. text-indent:-9999px
. Then when we click on that link the Dotted line appears like in the sample image below. What's the solution for this?

- 22,731
- 9
- 56
- 78

- 6,880
- 18
- 61
- 88
-
4Please don't remove that, it's there for sake of accessibility. – Jan 18 '12 at 08:03
-
15http://outlinenone.com/ – Jan 18 '12 at 08:05
-
Duplicate: http://stackoverflow.com/questions/1142819/how-to-remove-dotted-border-around-active-hyperlinks-in-ie8-with-css *(but please see accessibility comments above!)* – JohnB Jun 07 '12 at 22:47
-
I landed on this by using the wrong search term. I recommend anyone reading this to also be aware of this [underlines in IE](http://stackoverflow.com/questions/2041388/how-to-remove-the-underline-for-anchorslinks) – JGallardo Aug 19 '14 at 02:28
18 Answers
For Remove outline for anchor tag
a {outline : none;}
Remove outline from image link
a img {outline : none;}
Remove border from image link
img {border : 0;}

- 39,603
- 20
- 94
- 123

- 1,982
- 1
- 12
- 6
-
1Thank you, Discover. That had been bugging me for a long time -- not just the hyperlinked pics in IE, but regular pics w/ no hyperlink. It was annoying until I found your answer (via Google, not Stack, oddly enough). – Jason Weber Jan 16 '12 at 08:01
You can use the CSS property "outline" and value of "none" on the anchor element.
a {
outline: none;
}
Hope that helps.

- 3,440
- 25
- 22
For Internet Explorer 9:
a:active, a:focus {
outline: none;
ie-dummy: expression(this.hideFocus=true);
}

- 5,506
- 4
- 29
- 30
-
This one the only when that works in IE properly how ever it causes a page flicker on load. – Alexei Tenitski Sep 01 '12 at 22:36
Please note that the focus styles are there for a reason: if you decide to remove them, people who navigate via the keyboard only don't know what's in focus anymore, so you're hurting the accessibility of your website.
(Keeping them in place also helps power users that don't like to use their mouse)

- 5,055
- 4
- 25
- 31
-
We are not removing :focus style. just adding style outline:none so. other default style will be there. – Wasim Shaikh May 03 '09 at 17:06
-
1What is the "other default style" then? As far as I know there is only one, the dotted line. – Wolfr May 03 '09 at 19:40
-
1Ok.. May be we can use Diffrent style for Screen Readers. this may be Solution for Accessibility. – Wasim Shaikh May 04 '09 at 04:10
-
Not only screen readers use the outline, some people also like browsing websites which their keyboard. – user2019515 Mar 05 '13 at 15:25
There is the same border effect in Firefox and Internet Explorer (IE), it becomes visible when you click on some link.
This code will fix just IE:
a:active { outline: none; }.
And this one will fix both Firefox and IE:
:active, :focus { outline: none; -moz-outline-style: none; }
Last code should be added into your stylesheet, if you would like to remove the link borders from your site.

- 1,825
- 3
- 21
- 26
-
1Thanks Mike, This one is really Good Answer. but Using -moz-outline-style: none; is not Valid CSS. still this one is Good Option – Wasim Shaikh May 03 '09 at 17:05
include this code in your style sheet
img {border : 0;}
a img {outline : none;}

- 196,159
- 39
- 305
- 313
I hope this is useful to some of you, it can be used to remove outline from links, images and flash and from MSIE 9:
a, a:hover, a:active, a:focus, a img, object, embed {
outline: none;
ie-dummy: expression(this.hideFocus=true); /* MSIE - Microsoft Internet Explorer 9 remove outline */
}
The code below is able to hide image border:
img {
border: 0;
}
If you would like to support Firefox 3.6.8 but not Firefox 4... Clicking down on an input type=image can produce a dotted outline as well, to remove it in the old versions of firefox the following will do the trick:
input::-moz-focus-inner {
border: 0;
}
IE 9 doesn't allow in some cases to remove the dotted outline around links unless you include this meta tag between and in your pages:
<meta http-equiv="X-UA-Compatible" content="IE=9" />

- 912
- 11
- 26
-
@Sparky I believe we should offer an answer that is answering the question by telling about how to do this in most used browsers including MSIE as it was a widely used browser in 2014 and information on the MS meta tag and CSS that can be used for MSIE only Itwas just a part of my answer to offer support for most browsers including MSIE ... The Question was NOT about W3C Valid HTML or CSS... – jagb Oct 05 '16 at 04:33
-
@Sparky +1 because of that's true and we should never trust MS css/html/meta tags as they rarely think about W3C standards.... I didn't say it's good to use the Microsoft meta tags and their CSS code as the only browser that supports the MS code are MSIE and related MS browsers. As the requested answer to the question "How can I remove the outline around hyperlinks images?" – jagb Oct 05 '16 at 04:35
-
-
However, I was wondering if you could cite a source for your claim that this meta tag is necessary in *"some cases"*; and what those cases could be. – Sparky Oct 05 '16 at 04:54
-
Please read the [Microsoft website](https://msdn.microsoft.com/en-us/library/jj676915(v=vs.85).aspx) for some but not all information.. there are a lot of questions here on Stack Overflow, some of the Questions can be listed next to this Question on the right bar.. in some cases MSIE/EDGE can't display page content as the browser doesn't support it, in "some cases" the X-UA-Compatible meta tag is useful for MSIE/EDGE visitors. there is more info, a fix that will work is [here](http://www.validatethis.co.uk/news/fix-bad-value-x-ua-compatible-once-and-for-all/) I hope this is useful info to you – jagb Oct 05 '16 at 12:53
This is the latest one that works on Google Chrome
:link:focus, :visited:focus {outline: none;}

- 371
- 1
- 12
If the solution above doesn't work for anyone. Give this a try as well
a {
box-shadow: none;
}

- 487
- 2
- 7
- 21
in order to Removing The Dotted Outline href link you can write in your css file:
a {
outline: 0;
}

- 6,094
- 3
- 40
- 38
You can put overflow:hidden
onto the property with the text indent, and that dotted line, that spans out of the page, will dissapear.
I've seen a couple of posts about removing outlines all together. Be careful when doing this as you could lower the accessibility of the site.
a:active { outline: none; }
I personally would use this attribute only, as if the :hover
attribute has the same css properties it will prevent the outlines showing for people who are using the keyboard for navigation.
Hope this solves your problem.

- 5,221
- 5
- 24
- 39
I'm unsure if this is still an issue for this individual, but I know it can be a pain for many people in general. Granted, the above solutions will work in some instances, but if you are, for example, using a CMS like WordPress, and the outlines are being generated by either a plugin or theme, you will most likely not have this issue resolved, depending on how you are adding the CSS.
I'd suggest having a separate StyleSheet (for example, use 'Lazyest StyleSheet' plugin), and enter the following CSS within it to override the existing plugin (or theme)-forced style:
a:hover,a:active,a:link {
outline: 0 !important;
text-decoration: none !important;
}
Adding '!important' to the specific rule will make this a priority to generate even if the rule may be elsewhere (whether it's in a plugin, theme, etc.).
This helps save time when developing. Sure, you can dig for the original source, but when you're working on many projects, or need to perform updates (where your changes can be overridden [not suggested!]), or add new plugins or themes, this is the best recourse to save time.
Hope this helps...Peace!

- 21
- 3
-moz-user-focus: ignore;
in Gecko-based browsers (you may need !important, depending on how it's applied)

- 49,213
- 1
- 25
- 19
I would bet most users aren't the type of user that use the keyboard as a navigation control. Is it then acceptable to annoy the majority of your users for a small group that prefers to use keyboard navigation? Short answer — depends on who your users are.
Also, I don't see this experience in the same way in Firefox and Safari. So this argument seems to be mostly for IE. It all really depends on your user base and their level of knowledge — how they use the site.
If you really want to know where you are and you are a keyboard user, you can always look at the status bar as you key through the site.
Any image that has a link will have a border around the image to help indicate it is a link with older browsers. Adding border="0" to your IMG HTML tag will prevent that picture from having a border around the image.
However, adding border="0" to every image would not only be time consuming it will also increase the file size and download time. If you don't want any of your images to have a border, create a CSS rule or CSS file that has the below code in it.
img { border-style: none; }

- 285
- 4
- 5
Yes we can use. CSS reset as a {outline:none}
and also
a:focus, a:active {outline:none}
for the Best Practice in Resetting CSS, The Best Solution is using common :focus{outline:none}
If you still have Best Option please Share

- 6,880
- 18
- 61
- 88
-
20Isn't it a bit rude not to accept one of the other answers, whose content led you to your conclusion? – Pekka Aug 21 '10 at 14:27