I hear about designers and developers pulling their hair out all the time saying that Internet Explorer 6 doesn’t do what they expect or that it’s adding hours to development time but is it really the huge problem that everyone makes it out to be or does it just need a little more understanding?
In this article, I’ll hopefully cover the main problems that developers experience with Internet Explorer 6 and explain the solutions for these bugs.
Internet Explorer 6 isn’t perfect, far from it, but unfortunately while the user base for the outdated browser is still high, it’s in our best interest as designers and website owners to ensure that our sites work correctly for the majority if not all of our users.
There are bugs and problems with Internet Explorer 6 (and even IE7) but you may be surprised to hear that for myself, ensuring a website is compatible with IE6 adds next to nothing to development time.
How is this possible? I’ve got experience within the industry and have come across numerous problems, pulled my hair out for hours trying to make IE6 behave the same as other browsers and thankfully, am now in a position that when common problems repeat themselves and patterns emerge, it’s immediately recognizable as to what the problem is and how to solve it.
However, there are a few steps you should always use before you even tackle the problems of IE6.
Code using web standards
The first step is to ensure you have valid code. Create your website using semantic markup which validates and works in the modern browsers. Make sure you have a full, valid doctype and you should be able to create any design which works in Opera, Safari, Firefox and even IE7 with minimum problems and without using any hacks.
Once you’ve ensured that the foundations are in place, you can tackle any issue that IE6 has. Personally, I fix any issues as I encounter them as it’s easier to see which bug I’m dealing with and is easier to put a fix in as soon as it’s uncovered so I would suggest the same approach, especially for any beginner.
Below, is a list of the bugs that I find crop up most often and are the ones I not only find in my work but also are the causes of most problems for users posting on message boards and forums.
Double Margin Bug
The double margin bug in IE6 occurs when a floated element has a margin on the same side as the float.
For example, both of these examples will cause the margin to be doubled in IE6.
#navigation {
float: left;
width: 200px;
margin-left: 10px;
}
#content {
float: right;
width: 500px;
margin-right: 10px;
}
This will render as specified in IE7, Firefox, Opera and Safari but a bug in IE6 will cause the margin’s to render at double the size specified.
It can be particular problematic when dealing with pixel perfect layouts. For example, in the code above the two columns would sit nicely side by side in a 720px container for the modern browsers. However, in IE6 because the margin’s would be doubled, the content column would actually drop now that not enough space is available.
Double Margin Bug Fix
The fix for this is remarkably simple and doesn’t really make much sense, other than the fact that it works.
By applying display: inline; to the end of each style, it remarkably fixes the problem and causes no other side effects in any other browser.
#navigation {
float: left;
width: 200px;
margin-left: 10px;
display: inline;
}
#content {
float: right;
width: 500px;
margin-right: 10px;
display: inline;
}
I tend to find that this little bug causes the majority of layout issues but it’s amazingly simple to fix.
HasLayout
A definition of hasLayout can be found at satzansatz.de and explains it better than I ever could.
Layout is an IE/Win proprietary concept that determines how elements draw and bound their content, interact with and relate to other elements, and react on and transmit application/user events.
This quality can be irreversibly triggered by some CSS properties. Some HTML elements have “layout” by default.
Microsoft developers decided that elements should be able to acquire a “property” (in an object-oriented programming sense) they referred to as hasLayout, which is set to true when this rendering concept takes effect.
This can cause some strange effects with some elements and the particular problem that I usually encounter is when dealing with float clearing but it can also cause problems with boxes treating properties incorrectly as well as various margin issues.
I’ll focus on the main issue that I experience with hasLayout but it’s worth considering that a problem you’re experiencing may be due to this also.
HasLayout Example
I’d use the following CSS for a very simple container that holds navigation and content columns.
#container {
background-color: #CCC;
overflow: hidden;
}
#navigation {
float: left;
width: 200px;
margin-left: 10px;
display: inline;
}
#content {
float: right;
width: 500px;
margin-right: 10px;
display: inline;
}
Using overflow: hidden; on the container clears the float’s in the modern browsers and also applies “Layout” to IE7. However, overflow doesn’t apply “Layout” for IE6 so we need to use another value.
Using a position, float, width, height or zoom will apply layout but some can create undesired effects in modern browsers so what’s the easiest and best fix?
HasLayout Fix
I tend to find that the best method is to apply a width or height. Quite often, you won’t actually want to apply a width or height so the best way of applying this is to use the star hack to apply a small height to IE6 and below only.
This has the advantage that IE6 treats any height as a min-height and will therefore resize itself accordingly anyway.
Therefore, if you add a 1% height, this will correct the HasLayout issue.
#container {
background-color: #CCC;
overflow: hidden;
}
* html #container {
height: 1%;
}
#navigation {
float: left;
width: 200px;
margin-left: 10px;
display: inline;
}
#content {
float: right;
width: 500px;
margin-right: 10px;
display: inline;
}
Using this method will fix most HasLayout issues so is something worth considering if you’re unsure as to why IE6 is displaying the way it is.
Small Height Bug
I’m not sure what the real name is for this bug but I used to encounter it quite frequently within my designs and it occurs when a small height is specified but IE6 seems to completely ignore the height.
For example, the following will render correctly in all the modern browsers but for some reason, IE6 treats the height differently and refuses to collapse down to the 2px height specified.
#corner {
width: 10px;
height: 2px;
background-color: #C00;
}
Small Height Bug Fix
The problem seems to be caused by IE6’s unwillingness to collapse to a smaller height than the base font-size. It therefore will always by default render at a size that allows text to fit into the height available and it’s this that is stopping the height from collapsing.
So to fix this, all we need to do is set a font-size: 0; within the rule.
#corner {
width: 10px;
height: 2px;
background-color: #C00;
font-size: 0;
}
I’ve recently also discovered another solution which should have exactly the same effect. Because the box is stretching to allow for content overflow, we can also specify overflow: hidden; which will cause the box to honor the 2px height and also collapse.
#corner {
width: 10px;
height: 2px;
background-color: #C00;
overflow: hidden;
}
Both of these solutions will fix the issue even as far back as IE5.01 and won’t cause any problems in the modern browsers.
Summary
By no means is this an extensive list of IE6’s browser bugs but in my experience, these are the most common that account for 99% of all browser rendering issues so if you can get a good understanding of these issues and remember their fixes, hopefully your development time should start to drop for the troublesome browser.
Please feel free to comment though if you have any experiences of other bugs or have a browser bug that you’re unsure how to identify.
E7san
1 year ago
hi dev
Thx alot 4 this usefull artical .
Matt
1 year ago
great explanation and fix. I’d been struggling for a day trying to work out why IE6 was having issues – after reading the article it took 5 min to fix.
Botnerd
1 year ago
Thank you very much!!!. It’s the best thing I ever found on earth. It helps me reduce more than 5 hrs fixing IE6 bugs and some unsolvable bugs.
Great IE6 Tricks | The Saucy Mare
1 year ago
[...] Dave Woods IE6, tricks [...]
27stars » Blog Archive » The magic IE 6 fix!
1 year ago
[...] the solution is out there – and its not even a hack! I ran into the article <a href = “
hollyheisey.com » Blog Archive » Some Help With IE Bugs
1 year ago
[...] Fix the Big Problems: fix the big IE6 issues
asti
1 year ago
Thanks a lot for this article. I’ve come across most of these bugs before except the height issue (which just happened to be the issue I was having when I read this article) Thanks again.
Chris O'Donnell
1 year ago
It seems like you know what you’re talking about based on this article and the “HTML and CSS expert” title you give yourself – but why, then, are you using a free CSS template… Did you design it or did you pick it up from the link in the footer?
Dave
1 year ago
Hi Chris,
It is a free template but am currently in the process of create my own theme which should be live for the new year.
I initially used this template as a stop gap so that I could write some articles while I was working fulltime and doing some freelance work but will have my own theme online shortly
Cheers for the comments.
Top Gossips » Blog Archive » Obituary For IE6
1 year ago
[...] IE6 – CSS Bugs and Fixes Explained [...]
Dave Woods - Freelance Web Designer UK » 10 CSS Tips Every Web Developer Should Know
1 year ago
[...] IE6 CSS Bugs and Fixes Explained [...]
Spice
1 year ago
Hello Dave,
I do skins for invision and zetaboards. I don’t have a problem with the I.E. bug got invision, but lately it has been brought to my attention it is causing some grief on zetaboard especially for anyone using I.E. which I don’t. I design all my skins in FF. I read your article, and it sounds simple enough. My problem is I am not sure where in the CSS for zetaboards I am supposed to do this. I tried one fix and that didn’t work. Any help would be greatly appreciated as this is driving me crazy.
Spice
giannis
1 year ago
nice explanation of the bugs described. Thanks for posting
Gorkreg
1 year ago
Hi Dave!
Thanks a lot for that! No more _margin with invalid code. The display: inline; works great and validates!!!
Ally Ellis
1 year ago
Thanks loads Dave,
this article has fixed my IE 6 woes. I am really new to CSS (i am php programmer) and I always thought it would be much harder to fix the bugs with IE6 than this.
Cheers
Ally
daphna
1 year ago
thx, the display:inline fixed my prob.
patrick
1 year ago
thanks for simplifying this topic. i don’t find IE6’s bugs to be all that troublesome to work around, and you did a fabulous job of explaining a few very important fixes.
about what you said @ comment #13, i like pages to validate as well, but i thought that the *html hack caused pages to invalidate?
here’s my #1 tip, for what it is worth, and i’m sure that it is a “just understood” rule for you and many others:
i write my css for modern browsers first and make sure that everything displays properly there first. then, i go back and write the rules that will force IE5 and 6 to display as close to the modern browsers as possible.
if it’s a small site, i tend to agree with you and just include those rules in the same style sheets as the rest. but on larger sites i include an IE style sheet that loads last. because my css was written for the better, modern browsers it’s easy to go in and just delete the IE style sheet should that day ever come.
also, thank you for addressing this issue in the first place. i’m frankly sick of reading articles about how we, as DESIGNERS, should simply ignore IE 5 and 6. lots of end users in schools and corporations are forced to view websites in those older versions of IE, and designers should make every effort to make sure they have a good user experience.
Dave
1 year ago
Hi Patrick, Thanks for the feedback. The * hack is valid, it’s just that it shouldn’t actually make any sense to browsers that make it such an odd one but it’s perfectly valid to use.
I do agree though that for larger websites then it is a good idea to put any fixes in an IE only stylesheet and I have started to use zoom: 1; to apply haslayout fixes for the older versions of IE.
I do also agree with your last point although it does really depend on the site and what visitors are being targeted. For example, I’d have no problems ignoring IE6 users for my own personal website which is aimed at other web designers, however I would always ensure a website worked fine in IE6 for any client website at the moment.
Tetsuo
1 year ago
Useful little article, particularly the Small Height bug fix, which I hadn’t seen before.
I’ve seen this in effect in the past, but don’t see it as much these days as you usually only see it when you’re using empty or decorative elements, which I all but avoid now. Thanks for the tips
John Loudon
12 months ago
great!, thank you for posting this saved me a lot of re-work with a site I am working on.
I never understood that float: right; margin-right:0px; error (until now) but just looking at your problem and solved snippet I fixed it.
I’ll remember that for next time
Steve
11 months ago
Sorry, I disagree. It doesn’t matter if IE6 adds 5 minutes or 5 hours to development time, the point is that the hacks used to make it comply with standards ought to be unnecessary. If microsoft had followed the web standards that every other browser follows then we wouldn’t even be having this discussion.
Dave
11 months ago
Steve, I agree with you and am not happy that even on the day IE8 was released it was still behind all the other browsers in terms of the number of CSS selectors it supports so I’m as unhappy as you are.
However, this article was to illustrate that it isn’t as hard as many developers will have you believe once you understand the problems and that there is no need to pull your hair out for hours if you know about these little fixes.
Dave Hodgson
11 months ago
Dave – great article – clear, concise & just what the doctor ordered for a css newbie like me who despiseth of ie6.
Chris K
11 months ago
Much appreciated, spent a mere 20ish minutes trying to fix an issue but it could have been far longer if I didn’t jump right into google.
Dave Woods - Freelance Web Designer UK » Everything you need to know about browser testing
11 months ago
[...] IE6 Bugs and Fixes [...]
shabbir
10 months ago
IE 6 era ends
Eystein
10 months ago
Thank you for the Small Height Bug fix. I looked everywhere for a solution, and would not have thought of it myself. You saved my sanity!
shityoucantremember
9 months ago
Thanks, this is an excellent article.
Sayz
8 months ago
Thank you for taking your time and let me know the ways to fix IE 6 bugs, I’ll include it in my post. =)
קמפיי
8 months ago
[...] 13.5% מהגולשים בבלוג עושים את זה עם IE6 ויש רוב לאי
raj
8 months ago
nice but i need more explanation for browser compatiblity
IE6 Problems-How to See Them-How to Fix Them
7 months ago
[...] for these potential problems in the IE6-specific CSS file. (This is a link to a Web page that lists many of the major IE6 CSS problems.) Try the fix, upload the file and see what it looks like in [...]
Ray gee
6 months ago
Thanks a million times Dave, You saved me a lot of time!!! *yes*
Mark
6 months ago
Dave…
This post saved me a great deal of time (and I can see that I’m not alone in this!)
One comment to another poster who said that some of the solutions offered here would fail CSS validation. This is another reason for confining IE hacks to an IE-specific style sheet. That way, you can isolate the validation failures to the IE specific style sheet, while keeping your other style sheets valid.
sinisa
2 weeks ago
Thanks, especially, for small height bug.
(IE 6 should die, anyway).