Piskvor left the building
Piskvor left the building

Reputation: 92792

Does IE 8 have a limit on number of stylesheets per page?

In an answer about CSS, a user said:

Internet Explorer has is said to have a limit of 4096 CSS rules per file. Reference

Also, it has a limit on the number of style sheets you can embed in a single document. I think it is 20.

While the reference on MSDN seems to confirm this (and there's a blog post which confirms this in IE7), is this still the case for IE8?

Upvotes: 40

Views: 15664

Answers (6)

Matthew White
Matthew White

Reputation: 65

If you use NPM get Bless installed it sorts out the problem for you

Upvotes: 0

user3547136
user3547136

Reputation: 1

I was building a site and hit this issue myself. It was driving me batty until a co-worker pointed this 31 CSS files issue out. Looking into it what struck me that it's more complicated than that because IE8 seemed to be loading some of the styles from the sheet but not all of them. It was ignoring media queries and chained classes just like it was behaving in Quirks mode — even though it wasn't in Quirks mode and both those were in the same CSS file as other CSS that was being used. Once I aggregated the CSS files into one file it all worked fine. Anyway I just wanted to point out that somehow this 31 limit also seems to trigger something like Quirks mode.

Upvotes: 0

Chris Van Opstal
Chris Van Opstal

Reputation: 37587

Yes, IE8 (and even IE9 apparently) limit the number of style sheets to 31 per page.

Telerik has an article and test page which demonstrate the issue. According to comments in the same article, the 4096 rules per file limitation has been marked as Won't Fix in Microsoft Connect but I've been unable to verify that.

Upvotes: 55

Vacilando
Vacilando

Reputation: 3067

Thanks to the above testing script I have just confirmed this limitation (apparently 30) still exists even in Internet Explorer 9!

Upvotes: 3

Tor-Erik
Tor-Erik

Reputation: 1000

Microsoft claims the limit is 30, but the limit is apparently 31 according to Telerik. The Telerik blog also mentions a 4095 selectors per file limit.

Upvotes: 4

Daniel Renshaw
Daniel Renshaw

Reputation: 34187

This thread suggests there is a limit of 31 CSS references per page/CSS file but that you can achieve more than that by using @import and a nested hierarchy of CSS files.

More info from a Telerik blog on the issue making it clearer that this applies to IE8.

Upvotes: 5

Related Questions