Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove borders around links in IE? [duplicate]

Tags:

html

css

I have a navigation bar which consists of a <img> elements within their respective <a> elements. However, for some reason in IE its making a dark black border around the images. Its not doing the same in other browsers, I can't seem to figure this out... This is the html that I'm using.

<li>
   <a href="#">
      <span id="nav1">
         <img src="tt_1.png" />
      </span>
   </a>
</li>

I have about 5 links all written like that and I've used CSS to style it into a nav bar. On other browsers it comes out like this good bar

but on IE it comes out like this Bad bar :(

I've never encountered a problem like this before and what I've reserached to try and fix it so far haven't worked. Is there a way to take out these borders using CSS?

like image 222
Zeeno Avatar asked Oct 26 '11 23:10

Zeeno


People also ask

How do I get rid of the border on Internet Explorer?

add style="border: none;" to whatever creates the border or create a css with this attribute.

How do I remove the blue border around image links?

define border-style:none; in your CSS code for image. Using border="0" in image tag, this is worth for internet explorer. Apply border:none; css hope it will work out.. If not check out the css which is adding border, and try to override with your custom class.

How do I get rid of margin border?

You can remove this margin by setting the top and left margin to zero. Like the padding and border, the sizes of specific sides of the margin can be set using margin-left , margin-right , margin-top , and margin-bottom .

How do I disable borders?

Go to Design > Page Borders. In the Borders and Shading box, on the Page Border tab, select the arrow next to Apply to and choose the page (or pages) you want to remove the border from. Under Setting, select None, and then select OK.


2 Answers

TL;DR

Remove borders from all links and images:

a, img {
    border:none;
    outline:none; /* this breaks accessibility */
}

**Full version**

If you only want to remove borders from images that are links, you should do the following:

a img {
    border:none;
    outline:none; /* this breaks accessibility */
}

The only difference is that there is no comma between a and img meaning only images inside a-tags will have this rule applied

Pro tip: Use a css reset

Browser inconsistencies like this one are numerous, so web developers often use a "css reset" i.e. https://necolas.github.io/normalize.css/ or http://meyerweb.com/eric/tools/css/reset/. This will (among other nifty things) reset things like borders, margins, etc. on a number of elements so they render more consistently across browsers.

Note on accessibility

The dotted outline, that is often judged as disturbing by developers, has a very important function for keyboard users.

You should never remove it. If you do, you need to find another visual indicator of where focus is, by adding a :focus style

like image 155
Mathias Bak Avatar answered Oct 19 '22 00:10

Mathias Bak


I believe IE puts borders around images that are links. So you should be able to remove this by saying:

a img {
    border: 0;
}
like image 75
Jon Newmuis Avatar answered Oct 18 '22 23:10

Jon Newmuis