Tag Archives: developer tools

Internet Explorer Truncates Long CSS Files

I came across an interesting quirk in Internet Explorer a couple of days ago whilst working on a project for a client.

There is a section on their website that has an extensive set of stylesheets that is around 3,500 lines long. Combined with the stylesheets for the rest of the website, the total is about 6,500 lines.

The design was all finished and looked great in Firefox, Chrome, Opera, IE 7 and IE 8. However, then I did up the set of styles I mentioned that ended up totalling 3,500 lines. Due to the way I lay out my stylesheets, these started at about line 2,000. Which meant about 1,000 lines were after them.

While I’m working on something new I test in Firefox with Firebug and then once I’m finished I adjust for IE. So all of a sudden when I tested in IE 7 and 8, they are not displaying things correctly, including things in the design that were working previously. Using IE’s built in developer tools I was able to see that there were stylesheets simply not being applied to things that they should have been after about the 4,500 – 5,000 line mark. The entire stylsheet was loaded though and could be viewed.

I began tweaking things in the IE specific stylesheet since I couldn’t get it to work by editing the regular stylesheet. Once I realised that I could copy things directly from the main stylesheet into the IE one and it worked without tweaking, I started to think something odd was going on.

Cutting the extra 3,500 lines out put the site back to normal in IE, except for what those things affected.

If I put those lines in a separate stylesheet, everything worked perfectly fine again.

So it seems to me that for some reason IE just will not read more than around 4,500 to 5,000 lines in a stylesheet. It could perhaps also be total characters, however I didn’t test to find at exactly what point it stopped reading so I can’t be sure.  Fortunately, simply adding in an extra stylesheet did solve the problem, and given the nature of the extra CSS, it probably should have been done that way in the first place so that it could be loaded solely on the pages that actually need it. It should be noted that the total lines are still the same, they are just split between two stylesheets now, one of which is only loaded on certain pages.

I did a quick search for this but didn’t really come up with anything similar elsewhere, so if you have had a similar issue, I would love to hear about it!

It seemed to be consistently about the same place in both IE7 and IE8, so hopefully it won’t find it’s way into IE9.