4

With respect to IE's 4,095 CSS rule limit, would the following be counted as one or five rules:

.foo, .bar, .baz, .foo p, .bar a { property: value; }

I'm not 100% sure how the older IE browsers parse the rules. Thanks!

bjork24
  • 3,153
  • 7
  • 35
  • 46
  • 2
    It's per CSS rule. But be aware that it counts for selectors, not rules per se. This limit is only per file tho. You can just import multiple other CSS files to overcome that issue. I think IE's `@import` limit was around 35. I'll call you a hero of madness when you can achieve to get that many CSS rules :P –  Dec 30 '13 at 22:57
  • Oh btw; I just read that since IE10 you can have 65534 in a Stylesheet. But a HTML itself can still only hold 4095 (inline and in a ` –  Dec 30 '13 at 23:01
  • @Allendar: so my example rule would count as seven selectors against the 4,095... correct? Can you point me to any sources where the parsing rules are explicitly laid out? – bjork24 Dec 30 '13 at 23:03
  • The depth traversing might not count, but I'm not 100% sure. I try to avoid IE as much as possible :P. Here's a source; http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/10164546.aspx –  Dec 30 '13 at 23:06

1 Answers1

1

Judging by several people's attempts to solve this issue, it's a limit on selectors. Meaning you split each line at commas , when counting (as this example of a selector counter does: https://stackoverflow.com/a/20496041/624590 )

Which means your example counts as 5 points against the 4095 limit.

If you wish to prove it to yourself, take your IE browser to this page I set up: http://dylancodes.net/wayBack/ie9selectors/

It counts a few extra, to 4097, in a stylesheet formatted as:

.test0, .test1, .test2, ..., .test4097 { background: green; }

I've only checked using IETester software, but it seems the first three divs failed to get the color (counting from 0, so 4094 is the 4095th item, so there are three beyond the rule).

Community
  • 1
  • 1
DRobinson
  • 4,441
  • 22
  • 31
  • Right, traversing sets (`element > element > element`) doesn't matter. Good for that good ol' Microshoft. Maybe we should just sign a petition to drop the whole IE development. I could write a trilogy on the problems in that browser's engine and wrapping functionality. –  Dec 30 '13 at 23:22
  • Added a link to a simple test page, in case you feel like seeing your rule, expanded to 4098 selectors on a single line, in action. – DRobinson Dec 30 '13 at 23:42