CSS Hacks in IE7 | February 4, 2006

The closer Internet Explorer 7 gets to an official launch, the more concerned the IE dev team seem to be about the effect of CSS hacks. It started simply enough, with a few passing remarks that certain CSS bugs had been fixed and therefor hacks that use those bugs wouldn’t work on IE7. As things have progressed, these remarks started to sound a little more worried while the last few remarks actually sound seriously concerned.

I have to admit I can understand this concern up to a point, as nobody really knows what is going to happen. However I imagine the IE Dev team have been doing their research and have come across a number of broken sites. This is why they have asked developers to stop ditch CSS hacks and start using IE conditional comments instead.

The thing is, I really don’t understand the level of concern here. Maybe I’m missing something, but the majority of CSS hacks are used to send specific rules to Internet Explorer to make up for a deficiency in its CSS implementation. The IE dev team have fixed the majority of these deficiencies, so who cares if the hack no longer works? In fact it’s actually a good thing and I’d be more concerned if the hack still worked.

Take the humble Star HTML hack for instance. This hack is commonly used to supply rules only to Internet Explorer and not to any other browser. You would normally use this as part of the modified simplified box model hack to deal with IE5.x’s proprietary box model. The box model was fixed in IE6 as well as IE7, so what’s the big deal?

Similarly, I may sometimes use an underscore hack or child selector hack to compensate for Internet Explorers lack of PNG alpha transparency support or support for fixed positioning. With both of these CSS features suposidly fixed, where’s the problem?

It seems to me that their may be two issues at play here. First it appears that the IE team believes that CSS developers actively want some kind of filtering mechanism so they can filter out certain browsers. Personally I’ve never wanted to filter out a particular browser, just a particular broken browser version.

More importantly, I think the IE dev team are catering to a group of developers who build their sites with IE, rather than the standards in mind. If you build your sites expecting to use Internet Explorer 5.x’s proprietary box model and faulty overflow handling, of course your site will break on IE7. However it will also break on Firefox, Safari and any other half descent browser around. The problem isn’t the hacks themselves, it’s the way some developers have been using them. At least that’s my theory anyway.

Admittedly I’ve not actually tested IE7 yet, so this is pure conjecture. However if you’ve been using IE7, what’s your feeling? Are many websites seriously breaking due to CSS hacks, or are the IE dev team just being overly cautious?

Posted at February 4, 2006 11:20 AM


Andy Hume said on February 4, 2006 12:02 PM

I think you may be right - the standards based sites I have tested have as a rule faired very well in Beta 2. Although I don’t know which specific hacks some of those sites may be using, the overall results seem to suggest that things will be ok for standards based developers.

This could be a big win for Web Standards as developers, managers, and other stake holders notice the better forward compatibility of sites built with standards.

Keith McLaughlin said on February 4, 2006 12:59 PM

If the IE dev team are being overly cautious then that can only be a good thing. It’s better than their previous lack of interest in web standards.

Michel Fortin said on February 4, 2006 1:02 PM

I think you’re right, standard-compilant sites won’t suffer much. The problem is of course that they need to address all of the issues at the same time they remove the hacks.

Currently, my website suffer a little from IE7 beta 2, because it doesn’t undertand max-widht on the body (and maybe elsewhere). I’ll see what happen with the final version.

jordan said on February 4, 2006 1:50 PM

In a way, the IE team is in a very bad position with this whole thing.

On the one hand, it seems they really do want to adhere to the standards, and become a good citizen of the browser community.

On the other, they’re a massive force in the browser industry, and have users from all levels of experience that won’t understand why their favourite site suddenly looks like a mess and isn’t going to be fixed for a year.

While I can’t say I’m satisfied by what they’ve accomplished—there’s still a long way to go—I think they’ve done pretty well considering the difficulty of the task they’re faced with.

Matthew Pennell said on February 4, 2006 3:14 PM

I think a lot of the problems we are seeing (and the negativity being generated towards Microsoft and the IE7 developers) is due to the fact that there are some glaring inconsistencies in what they have implemented in this Beta 2 version.

The Tan Hack (* html), expanding height boxes and broken float implementation are gone; but still no min-width or min-height. This combination means that a lot of what we were using those hacks to get around still don’t work - but now the hacks don’t work either!

Hopefully they will address some of the big problems in the next Beta or in the final release, otherwise many developers will be working late nights to fix broken sites.

Andy Budd said on February 4, 2006 3:44 PM

Don’t get me wrong, I think the IE dev team have been doing a wonderful job so far. I’m just a little confused by the increasing urgency of their “don’t use hacks” messages, when most of the hacks are actually used to overcome deficiencies which they have already fixed. However I do agree with the max and min issues and hope this is something they include later on.

Ben Ward said on February 4, 2006 3:57 PM

Matthew Pennell’s example above is the crux of this whole situation.

We’re using hacks to take advantage of CSS features that are consistent in more modern browsers, but IE7 has taken away those hacks before achieving the same level of CSS support.

My worry is if they don’t get the same levels of support (especially something as fundamental as min/max-height). If they don’t release something to the same standard of, say, Firefox 1.0, it could be a really frustrating transition.

I’m not convinced that they’re right to disable the hacks until after they’ve implemented sufficient CSS to match the way people have built their sites. We’ll just have to make do.

Mani Sheriar said on February 4, 2006 5:41 PM

I agree with Ben.

I was most unsettled to learn that the ignoring of the “!important” declaration is still a factor of IE7beta. I used to use !important a lot as a “hack.” I would set the real value of something and declare it !important, and then reset that value for IE.

Now I fear that that IE7 will fix many of the bugs that forced me to override the real value, but it will still adhere to the hacked value, since it still doesn’t recognize the importance of !important.

Sigh. This could be a nightmare.

Claire said on February 4, 2006 5:51 PM

In the rounds of testing I’ve done, the use of the * html hack to give IE a width or height, a common workaround for some bugs is seeming not to be a problem as they’ve fixed a lot of the actual bugs as listed on PIE.

BUT hasLayout, the root cause of many of IE’s problems is still there and still a problem in some cases. e.g. containing floats ~ IE7 hasn’t introduced this capability to the overflow property, so they’ve not fixed it totally yet ;)
You can trip the hasLayout property another way though, without a hiding hack or in separate file if you’d prefer.

There is a serious problem with absolutely positioned elements and padding but I hope this is serious enough to fix before release

In general I agree they’ve made major inroads and I wonder if their “urgency” isn’t more just asking the community to take a leap of faith in order to help them leave hacks in the dark ages?

James AkaXakA said on February 4, 2006 10:17 PM

Yep. Zoom:1; to give an element hasLayout is still superior.

JaX said on February 4, 2006 10:34 PM

Dude, I can’t wait to see you at @media 2006 =)

Molly Holzschlag said on February 5, 2006 8:29 AM


On behalf of WaSP / Microsoft TF I implore you to be patient. This is a beta preview, it is not the final release.

Case in point, the !important delcaration problems hasve been fixed and will work properly in future releases.

WaSP has been working directly with the IE team to do whatever we can to advocate where necessary to help improve the scenario.

Will IE7 be perfect? No, but it’s not the IE developers at fault. I swear to you from the bottom of my own dark heart that the team is completely dedicated to supporting standards. However, they have a very difficult job ahead of them.

Quite honestly, I’m amazed at how far they’ve gotten considering the time and other factors (can you say “software tied to OS”?) involved.

Once again, I remind you: This is a beta. The reason the warnings and call for testing has to do with one simple fact: IE doesn’t want to mess up your day, and they need your help. Find a bug? TELL THEM. Or tell me.

It’s kind of like voting. If you don’t do it, you have no right to complain about the idiot that wins the election.

larry said on February 6, 2006 8:17 AM

Is the doctype deprecated? Why not add “behave like IE6 (with alpha-pngs, they are too useful)” and then build a standards-compliant browser from scratch?

Paul Solecki said on February 6, 2006 11:58 AM

Also we have to remember that this isn’t even a beta, it’s a beta2 preview!!

I really do congratulate the IE team for the development they’re doing on this and hope this is a model MS carries on with in their software development.

Michele Bugliaro Goggia said on February 8, 2006 7:33 PM

I truly hope that IE7 will sport a more standard support for CSS, including min-height and all the rest. It’d be a way so regain marketshare from Firefox.

Nick Gagne said on February 10, 2006 2:40 PM

There is a hack that works for all versions of Internet Explorer, including IE7 Beta 2. You can read about it here:

Ben Ward said on February 12, 2006 9:48 AM

Larry: That’s pretty much what they’re doing. Sortof. Certainly, all the new CSS fixes are only applied to pages rendered using IE’s standards-compliant mode.

That’s not the same thing as building a “new browser”, but they have declared that there’s more branching at work now than there was before.

The trouble with building a “new” rendering engine is that while there’s no reason why you can’t do it (heck, Netscape 8 runs the IE engine and Mozilla’s Gecko), the amount of work required to release anything is prohibitive. Microsoft are working to a fairly prompt release schedule so it just won’t happen.

What will be interesting is if, when they implement proper XHTML handling by way of the the application/xhtml+xml MIME type (IE8?), they could use that as a new way of branching CSS support and rewriting more substantial chunks of Trident.


Dreamwebmeister said on February 16, 2006 1:37 PM

i think its great for web developers, if only creating more work for us all and keeping us in our jobs … which is a good thing.

I also agree with your comments, work to standards, hacks are fine to mend broken standards compliance issues …..

Still, clients don’t always appreciate browser specifics.

Grammar Boy said on February 18, 2006 6:04 AM

I hope your book had a good editor because you seem to have a few problems with English spelling and grammar (suposidly <-> supposedly; their may be two issues <-> there may be two issues). What you write is worth reading though.