Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

CSS selector limit in IE #3901

Closed
aschempp opened this issue Feb 6, 2012 · 20 comments
Closed

CSS selector limit in IE #3901

aschempp opened this issue Feb 6, 2012 · 20 comments

Comments

@aschempp
Copy link
Member

aschempp commented Feb 6, 2012

IE versions 6, 7, 8 & 9 all have a limit on the number of selectors allowed in a single CSS file. Once the limit is reached, IE silently fails and just ignores any further CSS in the file leaving parts of your site totally unstyled.

http://blesscss.com/

Are we taking care/considering this in our CSS combiner?

@Serhii-DV
Copy link
Contributor

it's interesting... and what are the limitations?

@xchs
Copy link
Contributor

xchs commented Feb 6, 2012

http://support.microsoft.com/kb/262161

This problem occurs because the following conditions are true in Internet Explorer:

  • All style tags after the first 31 style tags are not applied.
  • All style rules after the first 4,095 rules are not applied.
  • On pages that uses the @import rule to continously import external style sheets that import other style sheets, style sheets that are more than 3 levels deep are ignored.

Test page (view this page in Firefox and IE): http://demos.telerik.com/testcases/BrokenTheme.aspx

@leofeyer
Copy link
Member

leofeyer commented Feb 8, 2012

Does this affect us?

@aschempp
Copy link
Member Author

aschempp commented Feb 8, 2012

It could, if the combiner combines a lot of CSS that will exceed the 4095 rules. Currently there is no way around this, but I don't have a clever idea either. I'd just keep it open atm...

@tristanlins
Copy link
Contributor

I created very complex websites with Theme+ and full combination of all stylesheets (including plugins). I never reached this problem until now. I think its not a critical problem, but we should not ignore this.

@aschempp
Copy link
Member Author

aschempp commented Feb 9, 2012

Thanks Tristan, thats exactly what I mean.

@leofeyer
Copy link
Member

Sill I close the ticket now, don't I?

@aschempp
Copy link
Member Author

I think its not a critical problem, but we should not ignore this.

Doesn't that mean we should keep it open for later?

@leofeyer
Copy link
Member

What will be different later?

@leo-unglaub
Copy link

@leofeyer i never had this problem in my projects but there is a simple solution. If you generate the css file from the internal database, simply count the selectors and after X selectors write the content into a different file.

@tristanlins
Copy link
Contributor

In the future, we will make more annimation with CSS3 instead of JS, means we have "a lot" more CSS Code than today. We may run into this problem in the future, when IE9 and maybe IE10 still have this limitations.

@tristanlins
Copy link
Contributor

@LeoUnglaub thats not correct, the combiner have to check the selector count, not the CSS File generator.

@leofeyer
Copy link
Member

The combiner also handles files from the file system. Are we supposed to write an algorithm to count the selectors? What about IE10?

@leo-unglaub
Copy link

@tristanlins thats right, i forgot about this.

@aschempp
Copy link
Member Author

Both have this problem... an individual file can exceed the limitation as well as the combiner. However, parsing the CSS to count selectors sounds very nasty...

@tristanlins
Copy link
Contributor

I think you can count the open curly braces {. The only "overhead" are the braces from the @media rules, but i think they can be ignored. (Normaly there are not many @media rules)

@leo-unglaub
Copy link

parsing the css files is not as hard as it sounds. As tristan said, you only have to get the content between the {} and split at the , and now you have the number of selectors. @leofeyer if you want, i can send you a pull request.

@tristanlins
Copy link
Contributor

@LeoUnglaub is right, i ignored that multiple selectors can be concatinated by , for the same block... but as he sayd, this should not be a big problem.

@leofeyer
Copy link
Member

It is a problem in my opinion though, because the reset script alone combines up to 40 selectors by comma. And almost every second format definition of my themes does, too.

Do we really need to worry about this at all? What about IE10?

@xchs
Copy link
Contributor

xchs commented Feb 14, 2012

IE10 raises the limits:

  • A sheet may contain up to 65534 rules
  • A document may use up to 4095 stylesheets
  • @import nesting is limited to 4095 levels (due to the 4095 stylesheet limit)

http://blogs.msdn.com/b/ieinternals/archive/2011/05/14/internet-explorer-stylesheet-rule-selector-import-sheet-limit-maximum.aspx

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants