Fix: CSS Problems in IE 8 With Over 31 StyleSheets

In my latest Web application, I went crazy trying to find out why a popup/overlay window style was acting up in IE 8 but was fine in the latest version of FireFox. After too many hours of frustration and dead ends, I took the issue to my friends at Telerik Support (the site I’m developing uses their excellent RadControls for ASP.NET AJAX suite).

Telerik diagnosed the problem immediately as too many stylesheets for Internet Explorer to handle. Huh?

I didn’t know about this limit (bug) of 31 stylesheets - but even if I had, I’d have wagered that I didn’t have that many. It turns out that many 3rd party controls generate styles as resources using an httphandler in the web.config file. Worse, even HTML  style tags count as stylesheets to IE!

In my case, the solution was to add Telerik’s RadStyleSheetManager  control to my master page. Suddenly, the troublesome style issue was gone.

From what I read on the InterWeb, Microsoft doesn’t plan to do anything about this limitation in IE 9, so it’s going to be around for a long while. You think Internet Explorer  would at least give us a helpful error message such as “Sorry, there are too many stylesheets for me to handle. The page probably looks weird because I’m a wimp and have given up applying the excess styles.”

For more info on the issue, check out this blog post on Internet Explorer CSS limits:

http://blogs.telerik.com/kamenbundev/posts/10-05-03/internet_explorer_css_limits.aspx

Full Disclosure: As a Microsoft MVP for ASP.NET, Telerik gives me a free licence to its control suite.

Ken

4 Comments

  • i agree with microsoft. they shouldn't do anything about it because there shouldn't be more than 31 stylesheet's on a page. shouldn't be anywhere near 31.

  • I have too agree with Darren on this. The fact that you can even hit that wall is amazing. The fact that Telerik knew immediately is even more amazing. How many times have they seen a site with more than 31 stylesheets? I mean, aside from the fact that 31 sheets would be a beast to maintain, that's 31 HTTP requests just to get styles!!!

  • I'd love to know how many stylesheets you were actually trying to use since it was obviously *more* than 31...

  • "The fact that you can even hit that wall is amazing."

    You're building a server control - where do you put the style info? Do you force the user of the control to put it in his global css file? Or do you include a separate CSS file in your assembly, that he can override if he chooses?

    Remember - it's not just css files that count against this limit. Each and every section counts as a separate css file.

    If you never need more than a handful of style pages or sections, either your pages aren't very complex, or you're not doing a very good job of modularizing them.

Comments have been disabled for this content.