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.
cal
2 years ago
Thanks for the article Dave, I know I’ll use it as a reference as most the other sites out there make the IE6 bugs more confusing.
Dave
2 years ago
Glad you find it useful. It’s a difficult subject to write about really as it’s quite a technical topic but I also like to keep my posts as simple as possible so that beginners can understand them as well so hopefully this article has achieved that.
Peter Gasston
2 years ago
I agree; the complaints of having to waste hours on ensuring compatibility with IE6 are exaggerated.
I wrote Five simple steps to alleviate IE6 frustration on this subject, which takes a similar tack to yours but is less technical.
Dave
2 years ago
Hi Peter, thanks for posting that link. I agree with it all apart from the last point.
I do use conditional comments when I need to support IE5.5 and below as supplying different widths for the box model makes sense doing it this way. However, I don’t see any advantages in applying the hasLayout fixes within conditional comments as apposed to the star selector hack?
IE6 wrongly implemented this and in future, no browser will render this the same as IE6 did so it is perfectly safe to use.
On the other hand, I have seen people taking advantage of Safari or Opera’s support for CSS3 selectors and applying hacks to these browsers which is obviously the wrong way to go due to the fact that once Firefox or IE8 support this selector, then they’ll find that their site breaks and will be back to square one.
But using old wrongly implemented hacks like the star selector hack shouldn’t pose any problems whatsover in my opinion and I’d suggest it’s more a personal preference rather than one method being correct over the other.
Jermayn Parker
2 years ago
Mmm I really hate that HasLayout bug…
I came across it in an earlier incident and tried to document it but this article seems to explain it better.
I enjoy your writing style. Thanks, good for future reference
Peter Gasston
2 years ago
I like to put all my IE fixes in a separate stylesheet so that my original CSS stays clean and easy to read. Plus, IE takes the extra slight performance hit of calling an extra stylesheet.
Dave
2 years ago
@Jermayn – Thanks, I’ve never really excelled at writing so just try and put it across as if I was explaining it to someone face to face, hopefully that works.
@Peter – I had this discussion with someone on Sitepoint and we ended up deciding that the performance would be minimal depending on the amount of hacks. Obviously the few extra lines of code in a stylesheet would only affect IE but the consideration that the actually conditional comment would be using space within every page of the site would also effect performance, albeit slightly.
For complex pages that are going to require lots of hacks then I completely agree as it does keep them separate but for simple sites that only need a few hacks then I tend to go for the star selector.
Julio Fragoso
2 years ago
nice post dude.
Can i translate to portuguese and post on my blog ?
Thankz anyway
Luke
2 years ago
Hey Dave!
This is a great article – thanks for writing it! It’s clear, and it explains how to fix a few of the painful IE6 issues out there.
Are you planning on writing any more, in relation to any of the other IE6 issues(like min-height/min-width not being supported)?
Cheers,
Luke
Dave
2 years ago
@Julio – Yes that will be fine, although a link to this article would also be appreciated.
@Luke – I wrote an article earlier in the week for a layout which implements min and max width which you might find useful and uses expressions to get around IE6’s problems.
http://www.dave-woods.co.uk/?p=140
In terms of min-height. I wouldn’t usually consider that to be a huge issue as IE treats height as min-height anyway so the following lines would treat all browsers the same
#container {
min-height: 100px;
}
* html #container {
height: 100px;
}
In most cases though, I leave height as auto and just let the content control the height but the above solution will work if you do need to use it.
Hope that helps?
Ben
2 years ago
1) Use conditional comments, not ‘* html ‘ to fix bugs. Its harder to organise, and doesn’t work with IE 7.
2) Use zoom: 1; to apply hasLayout in IE 6/7, since it has no visual value, (saying zoom to 100%) so is far safer to use.
Reymond
2 years ago
Great post, can I translate this in spanish to use in my Blog?.
Thanks dude!
Dave
2 years ago
@Ben, Thanks for your comments.
1 – In most cases you shouldn’t need to apply the hack to IE7 anyway so that shouldn’t be an issue. For a few small fixes, I don’t see any harm in placing the star hack immediately after the initial code and can actually be easier to organise and maintain. As I mentioned earlier though, it’s really down to personal preference.
2 – Whilst zoom works for applying “Layout” it is also invalid and therefore your CSS won’t validate. Using height: 1%; for IE6 is perfectly safe to use as IE treats this value as a minimum so as long as it’s served to IE6 and below only, then there will be no issues.
@Reymond – Sure, a link back to here would be greatly appreciated though
Dave Woods - HTML, CSS, Web Design » IE6 - CSS Bugs and Fixes Explained « Hotware: Dirk’s Software Blog
2 years ago
[...] January 18, 2008 Dave Woods – HTML, CSS, Web Design » IE6 – CSS Bugs and Fixes Explained [...]
Jay
2 years ago
display: inline; also fixes problems with horizontal lists, from my experience.
Drove me crazy!
Smarky
2 years ago
Hey this is great, I would really recommend turning this into a full blown guide, let this be the first draft of sorts and publish examples that we can see (with screenshots et all) I don’t get what you mean by HasLayout Fix however i guess i shouldn’t be hacking CSS to work with Ie 6 at half one in the morning! heh
Ben
2 years ago
A simple message: THANKYOU (for the the fix to the “Small Height Bug”)
Robin’s Blog» Blog Archive » IE6 - CSS Bugs and Fixes Explained
2 years ago
[...] Read the rest of this great article at Dave Wood’s site This entry was written by Robin Wood and posted on January 18, 2008 at 9:53 am and filed under CSS Resources. Bookmark the permalink. Follow any comments here with the RSS feed for this post. Trackbacks are closed, but you can post a comment. [...]
links for 2008-01-18 | IndianGeek
2 years ago
[...] Dave Woods – HTML, CSS, Web Design » IE6 – CSS Bugs and Fixes Explained (tags: css ie webdesign hacks ie6 hack) [...]
links for 2008-01-18 « toonz
2 years ago
[...] Dave Woods – HTML, CSS, Web Design » IE6 – CSS Bugs and Fixes Explained (tags: css ie hacks web) [...]
Vinny Carpenter’s blog » Daily del.icio.us for January 18th
2 years ago
[...] Dave Woods – HTML, CSS, Web Design » IE6 – CSS Bugs and Fixes Explained – In this article, I?ll hopefully cover the main problems that developers experience with Internet Explorer 6 and explain the solutions for these bugs. [...]
mwhenry.com » Blog Archive » Front-end Development Link Roundup
2 years ago
[...] IE6 – CSS Bugs and Fixes Explained Another nice reference post. Dave Woods looks at a rogues gallery of cross-browser rendering issues. [...]
coliss
2 years ago
Hi! Dave.
Thanks for the comment.
There are helpful also to the Japanese person.
Shy
2 years ago
Hi Dave, thanks so much for the Double Margin Bug Fix
Ben
2 years ago
Hi Dave!
I had given up on getting my personal site working in IE6 until I found this trying to get another site to work. A couple of display:inline and one font-size:0 later, it looks 99% like it’s supposed to instead of the 5% before!
Thanks so much for these tidbits!
sv
2 years ago
Thanks for a great post, Dave!
Your tips saved me a lot time, especially the HasLayout fix.
Good luck.
sv
2 years ago
… as well as “Small Height Bug”!
Max
2 years ago
I appreciate the post Dave, but I have to disagree. CSS is only a minor part of what is wrong with IE6 (and IE7)
The DOM, and JavaScript for IE is severely broken.
Of note, here are 30+ bugs in IE that will drive any developer up the wall,
http://webbugtrack.blogspot.com/search/label/DOM%20Methods
and they include everyday things like calling .getElementById(), or setAttribute()
Dave
2 years ago
Hi Max, Thanks for your comments.
My specialist area is design, HTML and CSS so unfortunately I’m only really able to comment on this area and getting the look and feel of a site right which is a big enough topic to cover on its own anyway.
Thanks for the link as well though as it may prove useful to others who deal with JavaScript and lets hope that IE8 has corrected most of those bugs (although I suspect it will have introduced some new ones).
Future.co.uk
2 years ago
Hi Dave, thanks for the Double Margin Bug Fix writeup this has solved all of my CSS issues…
… Where do I pay
Ryan
2 years ago
Great post. Appreciate the fixes for the IE bugs. It seems like every site I do, I run into the usual bugs. I did find a cool Dreamweaver extension for creating valid CSS layouts VERY easily. Check it out at WebAssist: http://www.webassist.com/professional/products/productdetails.asp?PID=135&WAAID=649
Alex
2 years ago
Thanks for a highly useful post! I just encountered a new IE bug (new to me, at least, and I’ve been coding CSS since 2000). I also provide the fix.
When using CSS to provide a “you are here” highlight in a menu, nesting order makes the difference in formatting. It doesn’t matter if it’s nested correctly. IE likes things nested in a particular order. The break is that when you are on the highlighted page, IE adds a line, as if you had inserted a ‘br’ tag. Here’s what I encountered:
- I used ‘class=”name”‘ inside the ‘a href’ tag to identify the page for the highlight CSS
- I used ’strong’ tags to boldface my menu items
- If the ’strong’ tags were nested outside the ‘a href’ tags, IE inserted an extra line beneath the item, but only when on the page matching the class name.
- If the ’strong’ tags were nested inside the ‘a href’ tags, then all was well.
Just another weirdness in IE that I thought I’d share with the class
Dave
2 years ago
Hi Alex,
That sounds like it was probably a haslayout issue but I’d need to see the code or a link to be able to provide a solution.
I suspect that providing display: block and a width (or other methods discussed in the article above) to both the strong and a tags would have solved this.
I know, you shouldn’t have to but that’s IE for you
Helen Olney
2 years ago
I’ve been tearing my hair out all afternoon wondering what was going wrong on a site I’m developing. After scouring the internet trying to find out, I found your information on the Double Margin bug. Many thanks for the fix. I can sleep well tonight!
Taming the Beast: IE6-Proofing Your CSS | Outlaw Design Blog
2 years ago
[...] are you going to need to put in your ie.css file? There are entire sites dedicated to Internet Explorer 6 bugs and workarounds; no point in rehashing them all here. Two that you’re sure to run into [...]
Parker
2 years ago
Hi Dave,
The small height bug can be fixed by changing the font-size or overflow, but for some reason this doesn’t seem to work when applying the style via javascript (element.style.fontSize = ‘0px’). I haven’t found a workaround for this yet. Weird, huh?
Parker
Parker
2 years ago
Whoops, disregard my previous post. I had left a console.log in my code call that was silently failing.
Jim
2 years ago
IE stinks. Every web developer should do everything possible to get Firefox widely used and this piece of garbage consigned to history where it belongs.
Dave
2 years ago
Hi Jim, yes IE stinks but if you understand why it does then it isn’t all that difficult to correct any bugs.
web design cheltenham
2 years ago
brilliant article you have helped me and my collegues a great deal – espically with the double margin trick.
I ran into a problem today I was using a image float in a div tag – but the float would not work correctly. this was because the text (p) had a width set to it – firefox displayed it correctly but good old ie7 could not understand a image float with a width set on the text.
Gary
2 years ago
Hey guys,
I tried out the above double-margin fix, but my website – currently online at healthspaguru.com is still getting that IE6 bug – can anyone shed some light?
Thanks in advance.
Taming the Best: IE6-Proofing Your CSS : Outlaw Design Blog
2 years ago
[...] are you going to need to put in your ie.css file? There are entire sites dedicated to Internet Explorer 6 bugs and workarounds; no point in rehashing them all here. Two that you’re sure to run into are [...]
maria
2 years ago
Hello! I have a problem in IE with layout. It is different from the layout in Mozzila. I cant fix the problem.Greetings!!!
Caroline
2 years ago
Hi Dave, just wanted to thank you for two of the bug fixes here that saved me a lot of time and aggravation! I doubt I would have been able to figure it out on my own.
Kirsty
2 years ago
Great all round list of bugs. Very useful thanks.
I found another bug thats not listed that caused me some problems called IE6 Multi Class Bug.
heres some info on it:
http://sonspring.com/index.php?id=102
I hope this helps people
Brittany Turcotte
2 years ago
Thank you so much for this article. Very useful!
Jeff
2 years ago
Brilliant.. thank you very much for the HasLayout hack. I never would have known that was the problem with my site. And even if I had known, I would never have thought of that 1% fix. Thanks once again.
Jack Santini
2 years ago
Thanks for saving my day with such a well explained article!! Knowing such an easy solution to the double-margin bug has saved me hours of time – I Have seen many articles on float drops etc that totally neglect to identify this bug as the MOST likely cause……
Max
2 years ago
Dave, a lot of thansk for you! Greate article (abd especially Double Margin Bug Fix!)
Gabriel
2 years ago
Great article. It was very helpful!