

All style tags after the first 30 style tags are not applied in IE (4-8) - timdorr
http://support.microsoft.com/kb/262161

======
DrJokepu
The fact that 30 is suspiciously close to 32 makes the impression that there's
some unholy C black magic in the background of the bug. I wish programmers
stopped doing stuff like that unless they really have to.

~~~
pwmanagerdied
Huh. A five bit range would give a max of 31, and if we assume that the
default/built-in stylesheet knocks another off, that's 30.

I agree with you, though I think I'd prefer this to hint at the reason over it
being an entirely arbitrary descision. Making such a choice for a bad reason
is still preferable to making it for no reason.

~~~
kingkilr
Yeah, I'm hoping it's that. Purely arbitrary would just be... stupid.

~~~
Periodic

        struct Element {
            // Update: apparently 16 wasn't enough.  Raised to 30 to pass test #452
            StyleData styles[30]; // No one uses more than 16 style parameters anyway.
        }

------
hackworth
also important to note: each stylesheet cannot have more than 4095 CSS rules,
in IE. experiencing this limit makes for some mighty interesting debugging.

~~~
billybob
If you've got a stylesheet with more than 4095 rules, I bet you have some
interesting debugging anyway.

~~~
callahad
It's not _that_ unreasonable. Scenario: You download the Fugue icon set
(<http://www.pinvoke.com/>). You're working on a template, and want to be able
to quickly try out different icons in different places. If you generate two
rules for each of the 2500 icons, you're over the limit.

------
samlittlewood
Ouch, I always try to make limits be 0, 1 or many - where 'many' is the limit
of physical resources.

~~~
snprbob86
A motivated, well documented, and standardized limit is sometimes appropriate.
This is not one of those times.

------
jamesjyu
This problem can be avoided by using @import statements within each style tag
to import more than 30 stylesheets. Some discussion here:
<http://drupal.org/node/228818>

Of course, you should avoid doing this in production anyway, and just asset
package your stylesheets into very few stylesheets. I've made a fork of the
asset_packager project to support this behavior after 31 stylesheets:
<http://github.com/jamesyu/asset_packager_ie_css_limit>

~~~
danw
There's a limit to the number of @import's you can have per style tag too, but
the imported stylesheets can also include @import's, from what I remember.

------
timdorr
And I love the link at the top (when not viewing the page in IE): Upgrade your
Internet Experience. Which links to IE, of course.

~~~
cmgarcia
I laughed hysterically when I saw that at the top after reading the first few
lines of the kb article.

------
MrMatt
I've hit this problem before - I use a separate stylesheet for each logical
(in my mind) group of styles - header, footer, main content, blog, and so on.
This way, I only have a few styles in each file, and it's easier for me to
manage (YMMV). I only combine them into a single stylesheet on production and
staging.

It's annoying to have to run the stylesheet combine when testing as when I
find problems, I have to sort through a mass of css and rerun the combiner in
order to test fixes.

OR

[http://www.i-marco.nl/weblog/archive/2006/06/24/time_breakdo...](http://www.i-marco.nl/weblog/archive/2006/06/24/time_breakdown_of_modern_web_d)

(But without the red section).

------
nkohari
I would never defend Internet Explorer, but I don't think this is really a big
deal. If you have more than 30 style tags on any page, something is very
wrong. IE has plenty of bugs and limitations that are much worse than this. :)

~~~
jsdalton
Someone brought this point up on proggit, and it was debunked by someone else
who pointed out that many developers break their stylesheets up into multiple
components for development purposes and then compile and compress them for
production. This bug prevents them from testing on IE effectively.

Genghis Khan might have had far worse faults than picking his nose at the
dinner table, but that still doesn't excuse the behavior.

------
Semiapies
Hmm, odd limit. I've never had more than 5 style tags on a page, though, and
fewer since I got into using yuicompressor.

Has anyone here actually run into this in practice? If so, how? Just curious.

~~~
n8agrin
Create a modular UI framework that allows modules to import their own
stylesheets. You hit this problem really quickly.

~~~
qeorge
Perhaps, but if you're including 30+ stylesheets in a given page you're doing
it wrong.

Every stylesheet is an extra (blocking) HTTP request. 5 is already too many,
but 30 is seriously impacting your user's experience.

~~~
DrJokepu
This bug can be triggered by inline stylesheets as well which do not create
additional HTTP requests.

~~~
qeorge
Fair point, but in what case does including 30 inline stylesheets make sense?

I'm hesitant to call this a bug.

~~~
pavs
Well, with MS, its a feature.

~~~
dkarl
At MS, it might be dictated by a coding standard.

More seriously, I was once treated VERY skeptically by an old-school
programmer (not at MS, never worked there) when I replaced some of his fixed-
sized buffers with resizeable ones. "If our customers are running workloads
that create more than 256 frooble node objects, I want to hear about it." Via
a bug report? Really? And then get a new bug report next year when the new
limit is reached? But he was adamant, and if it was up to him we wouldn't have
made the change at all. The way he worked, you _knew_ how many frooble node
objects the customer needed, and if you were wrong then you fixed the code.

------
archon810
I'm assuming this doesn't include the inline style="" params and only includes
<style> tags. At first, I thought it did and didn't believe such a limitation
went unnoticed by many for so long.

~~~
pyre
The inline style params are called attributes. Anything within the tag itself
-- of form token="value" -- is called an attribute (unless there is some
arcane SGML or HTML structure that I'm missing).

------
chaosmachine
Anyone want to guess why the number is 30?

~~~
matthavener
_Somewhere in Redmond, WA_

PageStyleTagsW tags[

 _Thinks for 5 seconds_

PageStyleTagsW tags[30]; /* should be enough for any page _/

_ Goes and gets a free soda*

Sometimes imposing arbitrary limits in C is a lot easier than manually
managing dynamic memory in the heap..

~~~
alttab
I've seen this where I work all the time. I've also seen code where the
developer created _25_ different structures named _structure_type_ _X where X
is 1-25, the size of the structure's internal buffer.

How do you deal with 25 different structure types with nothing different but
the name and buffer size? Why, a switch statement of course...

~~~
bradtgmurray
Sounds like a problem for C++ templates.

~~~
lanstein
Now you have two problems.

------
bengtan
Drupal's discussion of this (and with a workaround, I vaguely remember) ...
<http://drupal.org/node/256802>

------
billybob
"Resolution: To work around this limitation, combine multiple classes into a
single style tag."

Um... don't they mean multiple styles into a single class tag?

~~~
jeroen
No. What they mean is combining

    
    
      <style>
        .class1 { .. }
      </style>
      <style>
        .class2 { .. }
      </style>
    

into

    
    
      <style>
        .class1 { .. }
        .class2 { .. }
      </style>

