{"id":482,"date":"2008-04-23T05:45:51","date_gmt":"2008-04-23T12:45:51","guid":{"rendered":"http:\/\/css-tricks.com\/?p=482"},"modified":"2013-10-19T17:22:20","modified_gmt":"2013-10-20T00:22:20","slug":"ie-css-bugs-thatll-get-you-every-time","status":"publish","type":"post","link":"https:\/\/css-tricks.com\/ie-css-bugs-thatll-get-you-every-time\/","title":{"rendered":"IE CSS Bugs That’ll Get You Every Time"},"content":{"rendered":"

\"ie-bug\"<\/p>\n

IE 6 actually had the best CSS support of any browser when it first came out… SEVEN YEARS AGO. The little bugs in it’s CSS support still haunt us to this day. I still get comments from people who roundly reject any technique<\/a> that doesn’t work in IE 6. While I generally refuse to pander to IE 6’s limitations, I still feel it is important to make things look right in it whenever possible. Here are that major bugs in IE that’ll get you every time:
\n<\/p>\n

The Box Model<\/h3>\n

This is perhaps the most common and frustrating bug of all in IE 6 and below. Let’s say you declare a box like this:<\/p>\n

div#box {\r\n   width: 100px;\r\n   border: 2px solid black;\r\n   padding: 10px;\r\n}<\/code><\/pre>\n

IE 6 will calculate the width of the box to be 100px.<\/strong>
\nModern browsers will calculate the width of the box to be 124px<\/strong>.<\/p>\n

This kind of discrepancy can cause HUGE layout problems. I even think the IE version makes a little bit more sense logically, but that is not how the spec was written. IE 6 can actually get it right if you are in standards-compliant mode<\/strong>, which is rare these days as just using an HTML 4.0 transitional doctype will trigger quirks mode and the box model problem.<\/p>\n

I generally work around this issue by just not using padding on boxes I am using for layout. If that box has some text inside it in a <p> element, I’ll apply the padding it needs directly to that p element. Just side-steps the issue, but it works.<\/p>\n

 <\/p>\n

The Double Margin Bug<\/h3>\n

Using our box example from above, let’s say we need that floated to the right:<\/p>\n

div#box {\r\n   float: right;\r\n   margin-right: 20px;\r\n}<\/code><\/pre>\n

IE 6 will double the 20px to 40px<\/strong>. Again, causing potentially huge layout borks. The commonly thrown-around “fix” for this is to add “display: inline;” to the div. I’m not sure how this “fix” got so much traction, but its a bit impractical. We can’t set static widths on inline elements, now can we?<\/p>\n

I also like to side-step this bug whenever possible. If you really need to push that box away from the right side of it’s parent element, you can likely do so by adding padding to the parent element, which is more likely to keep your grid consistent anyway. Also don’t forget about padding. This bug does not affect padding, so you can often get away with adding padding to the side you need an achieve the same result.<\/p>\n

 <\/p>\n

No Min Widths \/ Min Height<\/h3>\n

Setting min-width and min-height on elements is such a natural and logical thing that it makes me tear up sometimes thinking I can’t count on them. IE 6 doesn’t just get it wrong, it just completely ignores them. Min-height is incredibly useful for something like a footer. Say your footer needs to be at least <\/em>100px tall because you are using a background image down there, but you don’t want to set a static height because you want it to grow nicely if, say, the text size is bumped up significantly. Min-height is perfect for this, but using it alone will get you no height whatsoever from IE 6. In a bizarre twist of luck, IE 6 treats the regular height property like modern browsers treat min-height, so you can use a “hack<\/a>” to fix it. I call it a “hack”, because I don’t really consider it a hack since it validates just fine.<\/p>\n

 <\/p>\n

Stepdown<\/h3>\n

Normally when floating objects you can count on them lining up vertically until they break. That is, you could if you weren’t using IE 6. IE 6 appends a line break effect after each floated block element which will cause “stepdown”. The fix here is to make sure the line-height in the parent element is set to zero (0), or that the elements being floated are inline elements. More on preventing stepdown here<\/a>.<\/p>\n

 <\/p>\n

No Hover States<\/h3>\n

Most modern browsers support hover states on just about any element, but not IE 6. IE 6 only support the hover pseudo-class on anchor (<a>) elements, and even then<\/em> you don’t get them if your anchor doesn’t have a href attribute. The solution here is to use a proprietary fix<\/a>, or just deal with not having hover states on everything you want.<\/p>\n

 <\/p>\n

No Alpha Transparent PNG Support<\/h3>\n

Kind of funny that Microsoft themselves developed the PNG format, but their own browser doesn’t natively support it (until IE 7)<\/span>*. I have a whole roundup of different fixes<\/a> for this. Do remember that regular non-alpha transparent PNG files work fine without any fix in IE 6, and are often better than their GIF sisters. <\/p>\n

*Update<\/strong>: I was totally wrong about the Microsoft thing, no idea how that got in my head. Tom Boutell<\/a> actually developed the PNG format. Thanks all!<\/p>\n

 <\/p>\n

So…<\/h3>\n

All these bugs are either fixable or side-steppable, but they will get ya if you don’t do your testing. My general philosophy is: design with the most modern techniques possible, but then just make sure it ain’t busted in older ones.<\/p>\n","protected":false},"excerpt":{"rendered":"

IE 6 actually had the best CSS support of any browser when it first came out… SEVEN YEARS AGO. The little bugs in it’s CSS support still haunt us to this day. I still get comments from people who roundly reject any technique that doesn’t work in IE 6. While I generally refuse to pander […]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_bbp_topic_count":0,"_bbp_reply_count":0,"_bbp_total_topic_count":0,"_bbp_total_reply_count":0,"_bbp_voice_count":0,"_bbp_anonymous_reply_count":0,"_bbp_topic_count_hidden":0,"_bbp_reply_count_hidden":0,"_bbp_forum_subforum_count":0,"sig_custom_text":"","sig_image_type":"featured-image","sig_custom_image":0,"sig_is_disabled":false,"inline_featured_image":false,"c2c_always_allow_admin_comments":false,"footnotes":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":[]},"categories":[4],"tags":[],"jetpack_publicize_connections":[],"acf":[],"jetpack_featured_media_url":"","jetpack-related-posts":[{"id":152670,"url":"https:\/\/css-tricks.com\/animated-media-queries\/","url_meta":{"origin":482,"position":0},"title":"Animated Media Queries","date":"October 11, 2013","format":false,"excerpt":"If you apply a transition on an element for a particular supported property, and that property ever changes, it will use that transition. If a class name on that element changes and the new class changes that property, it will transition (assuming what that class does isn't remove the transition).\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":187751,"url":"https:\/\/css-tricks.com\/styling-cross-browser-compatible-range-inputs-css\/","url_meta":{"origin":482,"position":1},"title":"Styling Cross-Browser Compatible Range Inputs with CSS","date":"November 5, 2014","format":false,"excerpt":"Styling for range inputs has improved dramatically since the release of IE 10. It is now possible to generate cross-browser compatible range inputs (sliders) using only CSS. In this tutorial, we will take a basic range input (): Screenshot of a range input, Mac Chrome 38 And turn it\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":147254,"url":"https:\/\/css-tricks.com\/svg-fallbacks\/","url_meta":{"origin":482,"position":2},"title":"SVG Fallbacks","date":"August 19, 2013","format":false,"excerpt":"UPDATE: Here's a more comprehensive guide to SVG fallbacks we've published. There is a very clever technique by Alexey Ten on providing an image fallback for SVG going around the internet recently. It does just what you want in the classic no-SVG-support browsers IE 8- and Android 2.3. If we\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":187949,"url":"https:\/\/css-tricks.com\/svg-animation-on-css-transforms\/","url_meta":{"origin":482,"position":3},"title":"SVG Animation and CSS Transforms: A Complicated Love Story","date":"November 10, 2014","format":false,"excerpt":"The following is a guest post by Jack Doyle, author of the GreenSock Animation Platform (GSAP). Jack has been deep in the woods of web animation for a long time, trying to make it easier and better. He's written here before, talking about how JavaScript animation can be the most\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":161608,"url":"https:\/\/css-tricks.com\/international-box-sizing-awareness-day\/","url_meta":{"origin":482,"position":4},"title":"International box-sizing Awareness Day","date":"February 1, 2014","format":false,"excerpt":"It's February 1st today, which I've decided to declare International box-sizing Awareness Day. In honor of, you guessed it, the most humble and undersung, yet awesome and useful CSS property: box-sizing. The date corresponds to Paul Irish's post where he introduced the concept of using it on every single element\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":161433,"url":"https:\/\/css-tricks.com\/boxes-fill-height-dont-squish\/","url_meta":{"origin":482,"position":5},"title":"Boxes That Fill Height (Or More) (and Don’t Squish)","date":"January 30, 2014","format":false,"excerpt":"It's hard to sum up all the awesome that is flexbox in a little ol' blog post. Although we gave it a shot here. Here, let's just try and focus on one thing that flexbox solves very nicely: the ability to have an arbitrary set of boxes fill up all\u2026","rel":"","context":"In "Article"","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"featured_media_src_url":null,"_links":{"self":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/482"}],"collection":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/comments?post=482"}],"version-history":[{"count":1,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/482\/revisions"}],"predecessor-version":[{"id":153530,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/posts\/482\/revisions\/153530"}],"wp:attachment":[{"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/media?parent=482"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/categories?post=482"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/css-tricks.com\/wp-json\/wp\/v2\/tags?post=482"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}