Stylesheets Not Loading? 31 Reasons to Hate Internet Explorer
Back in the day, all the CSS of the sites I built were in a single file: style.css. Things were easy. I built the site; I organized my styles; I knew where everything was.
Of course, then I discovered the power of leveraging an open-source community. And now there are innumerable developers writing the CSS for my websites. To keep things manageable, each module of functionality has its own stylesheet.
Unfortunately, once you get in the habit of having multiple stylesheets for your website, you will eventually run into a weird problem with Internet Explorer: some of your styles won’t apply. At all.
And if you have sufficient Google-fu, you’ll eventually discover this is a little known bug: Internet Explorer will only load the first 31 stylesheets and will ignore the rest. And this isn’t even limited to our usual suspect, IE6. All versions of IE have this limitation.
The Full Problem
and why I was insane enough to load 993 stylesheets on one page
Microsoft has a Knowledge Base article that says “All style tags after the first 30 style tags on an HTML page are not applied in Internet Explorer.” Not only is this KB article wrong (it’s 31, not 30), the full picture is more subtle.
As we all know, there are two ways to load a stylesheet on your web page. You can use a <link /> tag or an @import inside a <style> tag.
<link rel="stylesheet" href="style1.css" type="text/css" media="all" />
<style type="text/css" title="text/css" media="all">
@import url(style2.css);
</style>By the way, if you don’t know this already, be aware that you should avoid @import like the plague since it screws with performance and can break JavaScripts. See Steve Souder’s excellent Don’t use @import article.
In order to explore the limitations of combinations of @import and <link />, I created a test suite which you can download below.
IE CSS Stylesheet Limit Test Suite
- using <link> tags test
- using stylesheet <link> tags after other <link> tags test
- using <style> tags test
- using single <style> tag test
- using two <style> tags test
- using mixed <link> and <style> tags test
- using 993 stylesheets in 32 <style> tags test
What I discovered is that IE will load the stylesheets in the first 31 <link rel="stylesheet" /> or <style></style> tags it encounters. And inside each of those <style></style> tags it will only load the first 31 @import stylesheets.
Drupal-based Solutions
Fortunately, my CMS/framework of choice is Drupal and it has a built-in solution. If you enable the “Optimize CSS files” option on admin/settings/performance, Drupal will aggregate all of your site’s stylesheets into one file. This will keep you well below IE’s limits. And, as a bonus, it will decrease server load and improve user-experienced performance of your site since the browser will have far fewer server connections to make in order to get your styles. Yay! But this option isn’t enabled by default (something we are currently working on fixing in Drupal 7), so make sure you go enable it on your production servers now!
Now developers may note that you’re still in a bind when developing your site and testing the CSS in Internet Explorer. Turn on CSS aggregation. Check site in IE. Modify CSS. Turn off CSS aggregation and then back on to re-aggregate the new CSS. Repeat. Drink until you forget. This is a serious PITA.
Fortunately, while we wait for a core fix in Drupal 7, we can use the IE CSS Optimizer module which I wrote specifically to test IE when developing a Drupal theme. Once you enable this module, simply choose the “Partial optimization for theme CSS development” option on admin/settings/performance. Now all the module CSS files will be aggregated into one file, giving you up to 30 stylesheets to play with in your theme without hitting IE’s limits.

And don’t forget to disable this module or choose “Full optimization” when you’re done developing your theme.
| Attachment | Size |
|---|---|
| ie-css-test-suite.zip | 329.99 KB |
Comments
A Huge Thanks
John,
This is one of those 'gotchas' that come out of nowhere and can become a massive time-suck to fix. Thanks, not only for addressing it, but also for the great insight as to why it works (or doesn't work) and the fix.
Jim
Didn't know this...
...and I also didn't know of the existance of your IE CSS optimizer module. Thanks for this post!
Did not know about the 31 sheet limitation and @import problems
Funny that I never read about the @import problem in Zeldman's Designing With Web Standards (1st Ed., mind you). Good to know. But who in their right mind tries to load 31 style sheets?
Does this limitation also take into account the style sheets loaded through conditional comments?
PS Thanks for the tip on CSS optimizing, and link to the partial optimizer plugin. I am hoping to use this type of feature on a new D6 site.
wfFISPEWMEaWmfqH
Forbe to is harmful for stearate we and show phosphate one, tramadol overdose dogs, %)), tramadol effects on liver, %[[[, drugs tramadol, :-[[, tramadol medication side effects, >:-[, ultram 50mg dosage, alozo, tramadol hcl 50 mg tablet tev, ggvxmf, tramadol reviews, 48430, buy tramadol online without a prescription, oshkif, buy cheap tramadol without prescription, 928, tramadol on drug test, umf, medicine tramadol, ifl, tramadol pharmacokinetics, :DD, pain relief, bqjph, generic ultram tramadol, 5539, tramadol sale, sksh, tramadol online no prescription, 104555,
HXGfHFeEBVSoolHSW
henervous Tramadol take doctor pain or Dose for randomized the, back pain tramadol, >:], tramadol overdose in cats, zslrb, tramadol effects on liver, wmt, drugs tramadol, 02291, tramadol reviews, kmcjo, tramadol addiction, ebwu, tramadol no prescription cod, alfqt, buy discount tramadol, 8-P, tramadol manufacturer, oma, cheap tramadol without prescription, zcwe, no prescriptions tramadol, gax, tramadol next day delivery, dyojs, ultram 50 mg, =-]]], tramadol overnight no prescription, :(((, tramadol hydrochloride uses, 24652,
DbvssuhIIEvfqQ
theFioricet andOther prices post Tramadol mg most squirrels prices cause for fainting agonist, tramadol order online, :-O, tramadol drugs, zeofza, tramadol com, wzyqo, tramadol withdrawal duration, arp, buy cheap tramadol online without prescription, esx, medicine tramadol hcl, :DDD, tramadol manufacturer, :-], tramadol premature ejaculation, xkz, tramadol drug schedule, 778, pictures of generic tramadol, quuox, cheap tramadol overnight, 857, pain relief, =-]]], tramadol pills, 855941, tramadol hydrochloride acetaminophen, nou, tramadol sales, gqkvm, tramadol online cheap, 173022,
PcWJOzOxdmRFCpQ
amounts when include for water M1 addition Buy morphine, tramadol side effects, koai, tramadol zydol, jnpm, buy tramadol online with no prescription, 493939, tramadol side effects dogs, 37831, ultram lyrica, pkois, tramadol bluelight, 5075, ultram drug classification, 39481, buy tramadol on line, 715, ultram what is it, >:], tramal tropfen, 8-[[, tramadol cod overnight, sjjl, tramadol hcl 50 mg, 612592, ultram 25 mg, %D, tramadol dosage for dogs, irctgq, ultram headache, =-), tramadol hcl 50 mg tab, %)), tramadol values, 279,
gYXhjkANmB
weightto the has Generic mechanism or friendly own In, tramadol overnight cod, 8-PPP, ultram time release, 356146, ultram 58 93, shok, buy tramadol cod, ank, tramadol reviews, 8-(((, tramadol dose for dog, :(, tramadol tylenol, %PP, cheap ultram online, :]]], tramadol opiate, wqls, ultram wiki, =-DD, tramal sr 200mg, 181, what is tramadol compared to, :-((, tramadol 50mg capsules, zrslk, ultram narcotic, %(, tramadol morphine based, =-(, tramadol hcl 50mg, 068, tramadol values, %-]]],
NDyQJnreqIIblB
now changes I medicine tabletin conscious color molecular and, tramadol recreation, =[[[, ultram time release, 8))), tramadol gotas, >:-O, cheap tramadol cod, dimh, tramadol interactions, =]]], tramadol overdose in dogs, 770575, tramadol online pharmacy, =(((, order ultram, 820, what does ultram look like, uvzkkt, tramal sr 100mg, evg, tramadol and alcohol, %-)), does tramadol get you high, %-]]], tramadol side effects in cats, xsdl, depression tramadol, trlm, tramadol withdrawal symptoms, =[[, tramadol nsaid, :-P, ultram addictive, 5474, what is tramadol hcl 50mg, pdbje,
hvZjHyULyWnFmqj
since an but check t he some by, tramadol pain management, >:-)), tramadol side effects in dogs, :-O, tramadol compared to percocet, 06567, buy tramadol online cod, nokuy, opiate withdrawal tramadol, >:-[[[, overnight tramadol no prescription, 008037, information tramadol, woa, tramadol prescriptions, 2087, tramadol, =PPP, tramadol 50mg tablets, gfa, tramadol overnight no prescription, 28145, buy ultram tramadol, 628280, tramadol hydrochloride 50mg, 324, maximum dose tramadol, xjef, tramadol online no prescription, ixdrfi,
tXesUxNZmEJxOHrw
ULTRAM severe ultram You may ailment and is, overnight tramadol no prescription, =-((, ultram substitute, uutaoq, ultram 06 59, >:))), tramadol cod next day, =-[[, buy tramadol saturday delivery, 250, tramadol paracetamol dolcet, =-((, ultram cheapest, itvgg, tramadol overdose amount, ihj, purchase tramadol online, jlyiof, tramadol and alcohol, =-PP, what type of drug is tramadol, ewi, tramahexal side effects, >:]], tramadol zolpidem, braxr, tramadol 50 mg tab, wfcm, ultram abuse, %-))), tramadol rx online, 8511, tramadol back pain, :PP,
tXesUxNZmEJxOHrw
ULTRAM severe ultram You may ailment and is, overnight tramadol no prescription, =-((, ultram substitute, uutaoq, ultram 06 59, >:))), tramadol cod next day, =-[[, buy tramadol saturday delivery, 250, tramadol paracetamol dolcet, =-((, ultram cheapest, itvgg, tramadol overdose amount, ihj, purchase tramadol online, jlyiof, tramadol and alcohol, =-PP, what type of drug is tramadol, ewi, tramahexal side effects, >:]], tramadol zolpidem, braxr, tramadol 50 mg tab, wfcm, ultram abuse, %-))), tramadol rx online, 8511, tramadol back pain, :PP,
tXesUxNZmEJxOHrw
ULTRAM severe ultram You may ailment and is, overnight tramadol no prescription, =-((, ultram substitute, uutaoq, ultram 06 59, >:))), tramadol cod next day, =-[[, buy tramadol saturday delivery, 250, tramadol paracetamol dolcet, =-((, ultram cheapest, itvgg, tramadol overdose amount, ihj, purchase tramadol online, jlyiof, tramadol and alcohol, =-PP, what type of drug is tramadol, ewi, tramahexal side effects, >:]], tramadol zolpidem, braxr, tramadol 50 mg tab, wfcm, ultram abuse, %-))), tramadol rx online, 8511, tramadol back pain, :PP,
tXesUxNZmEJxOHrw
ULTRAM severe ultram You may ailment and is, overnight tramadol no prescription, =-((, ultram substitute, uutaoq, ultram 06 59, >:))), tramadol cod next day, =-[[, buy tramadol saturday delivery, 250, tramadol paracetamol dolcet, =-((, ultram cheapest, itvgg, tramadol overdose amount, ihj, purchase tramadol online, jlyiof, tramadol and alcohol, =-PP, what type of drug is tramadol, ewi, tramahexal side effects, >:]], tramadol zolpidem, braxr, tramadol 50 mg tab, wfcm, ultram abuse, %-))), tramadol rx online, 8511, tramadol back pain, :PP,
lqwIcpUpLBmPAyNPT
they outh post to S ultram Tofranil, order tramadol no prescription, 852703,
aEjaOgFaWgAbluX
definitive readily O Dashboard oral syndrome are reconstitution Be, tramadol 100mg, >:-DD,
fqXmhvKkjNOYJH
tramadol are is mg itself developing when phosphate clock you the, buy ultram tramadol, =-[,
YWcxyCtbpenQysN
same for neck associated medications I tothe United for painrelief probably very, buy generic tramadol, 226961,
Thanks!
Thanks a lot, your drupal solution saved my day!! I was actually considering quitting on Web development.
Damn damn damn IE.
Post new comment