Jens Oliver Meiert

To Be Clear (on Conditional Comments and Resets)

Post from August 24, 2008 (↻ December 12, 2016), reflecting Jens the .

This and many other posts are also available as a pretty, well-behaved e-book: On Web Development.

My articles on both Conditional Comments and “reset” style sheets belong to the most popular contributions regarding that matter not just on this site, but apparently on the Web. I appreciate the discussion, led with so much insight and passion.

Now, it looks like I could still clarify my standpoint. So let me summarize my main concerns, starting with a request to take the post titles with a grain of salt: “Why Conditional Comments Are Bad” is intentionally provocative, as is “Why ‘Reset’ Style Sheets Are Bad,” or rather, “When….”

Conditional Comments

The core problem with Conditional Comments is its impact on maintainability. By their very definition you have to link at least one additional style sheet from your HTML, unless, even worse, CSS rules are added within the document. And just as we avoid using font elements as they are presentational and usually mean HTML changes once we want to change the layout (which means a maintenance problem), we should avoid Conditional Comments as once we want to change (or even keep) the layout when a new version of Internet Explorer ships or an old version goes, we face a good likelihood to change the HTML, which translates to an unnecessary maintenance issue as well. Then we note, using templates or “search and replace” is a weak argument; one could apply it to font, center, align, and other presentational elements and attributes as well, claiming that they are not a maintenance problem either.

There are implications for collaboration as well, and we can observe these problems in practice: Since CC style sheets don’t necessarily use different selectors than the “regular” style sheets, developers either have to look for the same selector in at least two style sheets, which slows them down (especially in comparison to “hacks” which are usually close to all other rules), or they overlook them, implement another solution, eventually run into “weird” layout problems (because the CC style sheet overrides something or says something different), and maybe even add code that is unnecessary. That is just a logical problem, and it’s, to come back to my “socks” question, similar to putting one sock in one and the other in another place. This doesn’t make it easier to get to work in the morning because you end up needlessly looking for one or just go for another pair, basically driving the one you already had useless.

Even though we left out issues around standardization and compatibility, I hope this clarifies. Looking for solutions that neither use CC nor “hacks” is best, but at least “hacks” within style sheets, despite the implicit risks that hacks targeting “living” user agents bear, don’t mean HTML changes. That’s a great advantage.

Reset Style Sheets

My criticism regarding resets mainly focuses on the situation when they are used without any modification (something that Eric does explicitly ask for, yes), causing unnecessary since overwritten or even redundant code. In fact, observing use of resets in the wild confirms that this criticism is just, as they are often and actually used without any edits (in fact, they are sometimes explicitly used as a standalone, “don’t touch” style sheets).

What then makes me recommend not to use them at all—precisely, “a novice should not use them, an expert would not use them”—is that once you have to customize a reset, there is barely an advantage in using them anymore; the time spent can be used on the “real” style sheet instead, one that deserves the attention to make it as elegant and efficient as possible. This should be motivation for more than the perfectionists out there.

(Of later reset critiques a Google+ post probably sums it up best. If you’re looking to learn when a website uses a reset, check out the Reset Style Sheet Exposer Chrome extension.)

When Conditional Comments And Resets Are Not Bad

Conditional Comments and resets are less “bad” when they work for you. And with “work for you” I don’t mean just today, I mean tomorrow, at the end of 2009, and at the end of 2020.

When I’m so, well, passionately talking about this stuff I sometimes fail in making the case completely clear; blame that I’m no native speaker, or blame that I need to learn more about arguing, or both. However, I don’t take the time to “just provoke,” or to criticize other people’s work for the sake of criticism alone. I take it because I love our profession as much as you do (gosh, this is getting cheesy). And our profession needs discussions about maintainable, quality code.

About the Author

Jens Oliver Meiert, photo of July 27, 2015.

Jens Oliver Meiert is a philosopher and developer (Google, W3C, O’Reilly). He experiments with art and adventure. Here on he shares and generalizes and exaggerates some of his thoughts and experiences.

There’s more Jens in the archives and at Amazon. If you have any questions or concerns (or recommendations) about what he writes, leave a comment or a message.

Comments (Closed)

  1. On August 24, 2008, 10:51 CEST, Louis said:

    Very wise post Jens.

    I wonder though about your opinion on Reset stylesheet. It’s not hard to imagine that in a close futur, we will be able to use automated tools to compress stylesheets by overwritting rules that has the same selector, the way the browsers do.

    In that case, a reset stylesheet would not add any weight to the final file; it would only be a nice way to work truly from scratch, without having to remember the default stylesheet that comes with each and every browser, already on the market or to be released.

    Also, event that at the present time, we have not such automated tool I describe, I can’t imagine myself styling a page without *{margin:0;padding:0}.

    So here my point is that, talking of long run, wouldn’t it be necessary to consider the technical improvements the CSS world will probably go through?

  2. On August 24, 2008, 10:55 CEST, Kroc Camen said:

    A Reset is just an advanced
    * {margin: 0; padding: 0; border: 0;}
    except it works around <input>s.

    It means you can code from 0 and know your browsers are going to be more alike and not have to deal with your ULs working in one browser, but not in others.

    Sure, using them verbatim without knowing what you’re doing is ill-advised (Especially wasting a whole HTTP request just for that), but then no browser is perfect, so therefore neither can our code be.

  3. On August 25, 2008, 12:21 CEST, Andrei said:

    Why place the conditional comments in another stylesheet?

    It’s quite simple to apply:

    div#main {}
    /* IE specific for div#main*/
    div#IE6 div#main{}
    div#IE7 div#main{}
    /* end of IE specific div#main */

    all in the same stylesheet.

    Sometimes you really need to use specific targeting, and compromising your design for the sake of avoiding the use of conditional comments is the “lazy way out” IMHO.

    If anything, Apple themselves use CC’s on their site. For a multi-billion dollar company that has a strong interest in the web to use them must speak volumes about their “maintenance”.

  4. On August 25, 2008, 12:36 CEST, Andrei said:

    I’ve also re-read the past article you referred to.

    I still fail to see how conditional comments pose a maintenance problem. When IE8 is released, there is no need for you to update your past code. What for? If you specifically targeted IE6 and 7 (and did not use “gte” or “lte”), then there is no “maintenance” to speak of. If IE8 screws up your website, but your website works fine in FF and Opera, then conditional comments will actually save your life - because the update you would need to write would be for IE8, which is to be expected, given MS’s track record. Could you imagine having to rewrite ALL your code because of IE8? If you had CC’s there in the first place, the only adjustments you would have needed would be for IE8.

    And please do not say “but if your code works on all browsers…” - that is a rubbish Utopian dream. Blogs are simple enough to work on all browsers, but when your website requires far more complex layouts (such as flexible containers, several z-levels, and absolutely positioned objects), there is no choice but to swallow the CC pill.

  5. On August 25, 2008, 13:16 CEST, Jens Oliver Meiert said:

    Louis, thanks; as for tools, well, I think that quite a few companies do use some scripts to compress, merge, or do other things with their style sheets. Merging style sheets is not trivial though as this can very well mean layout issues due to its impact on the cascade, mostly due to changes in order.

    Kroc, I guess there are several types of resets, e.g. the margin and padding reset, Eric’s reset, or resets probably yet to be created that reset all user agent styles. The kind of reset in use is certainly interesting, but even more important is how it is used.

    Andrei, how can’t you place CC in another style sheet? Your example doesn’t use them. And, going for the simplified reply, font elements don’t need to mean a maintenance problem either…

  6. On August 25, 2008, 14:02 CEST, Rafael Madeira said:

    Every time I see someone talking about how one of the downsides of doing this or that with the CSS is that they might have to *gasp* alter the HTML at some point in the future, I have to wonder if they’ve ever actually built a website.

    In close to 10 years working in the field, I’ve never worked on (or even seen) a case where the site in need of an “aesthetic” redesign didn’t also call for a complete structural overhaul, save in cases of personal websites where the designer just feels like updating occasionally and, more frequently, is up for a challenge.

    In the particular case of Conditional Comments that you’re arguing, the damage can be as overwhelming as running the risk of changing a whopping one line of code sometime in the future. Surely there has to be a better way.

    Unfortunately, separation of content and presentation is, at this point, still a myth (look that up). You must know, not fear that you will need to modify your HTML countless times while creating or updating the templates, and that you are very likely to get back to it for minor, unexpected edits some time after you’re “done”.

    And those who have to crank out websites on a frequent basis know better than to sweat over the “ethics” of it, if you will. They know it is a part of life. Instead, they create practices to simplify their workflow. Practices such as CSS Frameworks, CSS Resets and Conditional Comments.

    “What then makes me recommend not to use them at all – precisely, ‘a novice should not use them, an expert would not use them’”

    The first reset to be made popular and shine light on the subject was devised—and just recently updated—by a person who can safely be considered an expert.

    “… once you have to customize a reset, there might be no real advantage anymore; the time spent can be used to go for the “real” style sheet instead”

    Unless you’re revisiting a reset because you realized that your actual usage doesn’t really reflect what’s there, and you intend to make permanent changes that will save time or mental load down the line, “customizing” a reset is missing the point entirely.

    Using a reset is creating a blank canvas that you can then build on top of. If your reset says “border=0″ but for this particular job you need “border=1″, you don’t edit the reset. You create a new rule and overwrite the reset. You spend time on the real stylesheet instead.

    And for those who go “well, then what’s the point of writing something you’re just gonna overwrite anyway”, the point is that, more often than not, you don’t overwrite the whole thing. But, most important, it’s one more step towards cross-browser consistency. You can just write CSS and later check in a lot of browsers and everything is pretty much the same, the inconsistencies much easier to pick out.

    Which, although possibly OCD (but designers are frequently neat-freaks anyway), feels much better than coding primarily for one or two browsers, and then checking it on 4 or more when you’re done only to find that somewhere down the line things started going wrong for one or three of them, and you’re not sure where to start.

    So I’m sorry, and it’s nothing personal, but I can only fathom criticisms like this (and you’re not the only one making them, Jens, so it’s really not personal) from people who match the following criteria:

    1. Don’t need to deliver coded, functional websites on a frequent basis;

    2. Have way too much time to spend on nothing interesting at all;

    3. Has a very high tolerance for mindless, repetitive manual labor;

    4. Have poor interns doing the actual manual labor for them, so they can brag on the internet about how you don’t see any need for it;

    5. Are even more of a neat-control-freak than people who employ these time-saving, mind-relieving methods, having an unshakable need to code it all by hand;

    6. Are letting some ideology get in the way of reality (and productivity);

    7. Any combination of the above.

  7. On August 25, 2008, 14:25 CEST, Jens Oliver Meiert said:


    In close to 10 years working in the field, I’ve never worked on (or even seen) a case where the site in need of an “aesthetic” redesign didn’t also call for a complete structural overhaul,

    and, nothing personal either, that exactly is characteristic for people who don’t want to or just don’t understand the “vision” behind separation of document structure and presentation, and thus don’t understand concerns like raised in this post either.

    There is nothing mystical about separation of structure and presentation, and it works (a larger commercial example I can think of is German, “CSS redesigned” in April). Apparently only experience can debunk this myth though—which is not possible when sticking with “excuses” or other people’s views on why all the presentational stuff is still necessary or must stay within the HTML, just how it is.

    Great stuff. Thanks for sharing your point of view!

  8. On August 25, 2008, 15:19 CEST, Nacho said:

    Although I find Eric Meyer’s Reset Styles cool and helpful, I actually feel that the vertical-align:bottom;
    used in the reset actually gives mor problems than the one it solves.

    Is actually necessary that atribute?

  9. On August 25, 2008, 18:09 CEST, Duluoz said:

    As someone who obviously can not be an expert, cause I’ve only been developing websites for a few years, I find it extremely troubling that I have no issues separating presentational and structural code. Maybe if I were an expert I would see my naivety and mix the two with ease? Maybe I live in Utopia Land? ;)

    I am of the same opinion as you Jens when it comes to both resets and conditional comments as you well know from previous comments.

    I also I do not buy the argument that one must use a framework to get work completed more quickly either. As someone who is constantly creating new sites both large and small, I’ve yet to say to myself, “I sure wish I had a framework and reset so I could spend time customizing it to fit my needs”. Whatever works for you though is great. But while you’re wasting time customizing, I wrote a custom style sheet, finished my work, and am outside playing. :)

    Call me a perfectionist, but to me, do it right (with the obvious caveats), or don’t do it at all. On the other hand, I’m glad there are people out there not willing to put in the work to create quality, highly maintainable websites, to keep others who will in business.

  10. On August 25, 2008, 23:31 CEST, Andrei said:

    Jens, to answer your question:
    (pardon the bad syntax - I didn’t want to lose anything, and I don’t have much time atm).

    I don’t use conditional comments in this sense:

    [target IE CC]
    [new IE specific stylesheet]
    [/close IE CC]

    You can, in fact, approach it like this: (which is what I use)

    [html body element tag]
    [target IE 6 CC]
    [div id=”IE6″]
    [target IE7 CC]
    [div id=”IE7″]
    regular content
    [close IE CC]
    [/html body element tag]

    What this does is basically create a new parent container div depending on which IE you wish to target. So, for example, your CSS only needs tweaks for IE6, only the IE6 parent div loads, and you can target IE6 in the same stylesheet, as such:

    /* normal div */
    div#main {}

    div#IE6 div#main{}

    and because all the other browsers ignore the divs that are inside the IE CC’s, there’s no need to readjust anything for the working browsers and thus, you only use one style sheet.

    Anyway, my explanation is rubbish, so here is a link to a much clearer one:

  11. On August 26, 2008, 6:37 CEST, Evan said:

    I typically use a less than IE7 Conditional Comment to include IE6 png Javascript fixes. I agree with you on the point that you shouldn’t necessarily deliver a separate IE stylesheet, but feel like using conditional comments to fix transparency issues for IE6 is a rather needed practice due to the poor support.

    Also agreed, is that you should almost always customize a CSS reset and not just include it untouched. Overwriting the default browser CSS, and then resetting the CSS, and then adding CSS to format elements the way you want them is a terrible practice.

  12. On August 26, 2008, 12:06 CEST, Louis said:

    Andrei’s technique is really interesting. Using CC on the body element in particular would allow to distinguish a page loaded in IE6 from a page loaded in FF.

    That’s very clever. I wonder what Jens think about it.

  13. On August 27, 2008, 10:32 CEST, Jens Oliver Meiert said:

    Nacho, it seems like Eric’s using the declaration vertical-align: baseline; which should work quite fine; however, I often use vertical-align: top; when dealing with tables—something that probably helps in your case too?

    David, glad to hear that, not just that we talk the same language :)

    Andrei, okay, got it. The issue remains though, or let me just ask how that does not affect maintainability in terms of avoiding HTML changes? How would you deal with Internet Explorer 8 or once IE 6 vanishes? Wouldn’t that require HTML changes? Apart from that, talking ID/class semantics, is that document then an “IE6”/“IE7”/“IE8” document, changing its supposed meaning without changing its function/content? I hope you know what I mean, I’d not just recommend to keep user agent information out of the document but rather really focus on bringing the probability and necessity of HTML changes down to an absolute, the unavoidable minimum.

    Evan, thanks for dropping by; as for the PNG issues, well, I did use child selectors in the first, 2005 edition of my CSS book (released before IE 7) to address this problem (using GIF background images as the default, and offering PNGs for browsers that happen to support both PNG and child selectors), see e.g. the first photo gallery (and its “Scotch Tape” style stickers). This is considered a “hack” (even though it’s perfectly valid CSS), yes, however, once there are problems you can easily change the style sheet and the sky is bright again […].

    Louis, I hope I shared my thoughts in an appropriate way, cheers :)

  14. On August 30, 2008, 0:36 CEST, Rodrigo said:

    I use Meyer`s reset and it saves me a LOT of time and kills most of the pain in handling cross-browser issues. I could say that I can`t live without it :D

    For CCs, I have a single rule for the entire website. I define a stylesheet for IE 6 and place it in my master template, so there`s no problem to mantain it.

    I don`t like IE hacks at all. I hate them. I prefer using another stylesheet just for the IE 6.
    On my last project, the IE6 SS had only 5 selectors, in order to fix some positioning.

    I think the point is whether you can develop your SS efficiently, so you don`t have to add workarounds for odd behavior.

  15. On May 27, 2009, 0:21 CEST, Olev said:

    I think using hacks is a bad idea. If a new Internet Explorer version comes out, then the hack might not work anymore and you would have to invent a new hack (for all of the sites and perhaps really fast!). That might not be possible, especially if you used several different hacks. This is what I would call a maintenance nightmare. On the other hand, CCs would target the correct versions (and using ‘lte’ syntax, perhaps if the new IE version is better at CSS support, you wouldn’t have to change anything at all). CCs are usually in the template or header/footer, so it’s easy to change the code - it is included from1 source. So I don’t agree with you about the maintenance issue.

    Also, I think you’re talking about minor cosmetical redesign when you say there should be no need for changing the (X)HTML code. Bigger redesigns usually include changing the structure also. The separation of structural and presentational layers doesn’t suggest you shouldn’t change one if you change the other. And redesigning a site doesn’t mean that you’re redesigning only presentational layer (perhaps you don’t need some section of the site anymore or need some additional elements).

  16. On November 6, 2009, 13:15 CET, Jacob Rask said:

    In a new redesign/-code, we are considering using a conditional comment for IE6, loading a specific style sheet. Then in a year or two, we will hopefully be able to remove that entirely without doing any extra changes to any code.

    @Andrei: That is an interesting approach. Quite often IE might need an extra wrapper anyway.

    However, I sometimes find myself having to use non-standard CSS like zoom: 1; in IE stylesheets. I accept using non-validating CSS in ie.css but not in my main CSS files.

  17. On January 27, 2010, 10:05 CET, kristof vandommele said:

    I’ve been using a system comparable to Andrei’s since early 2008.
    I found that maintaining add-on css-files for IE wasn’t very productive, so I rethought the way I used to target different IE-versions.

    After the body-tag, I include a couple of cc-spans with the respective IE-version as an ID. These spans get closed right before the /body.

    {if IE 6}{span id=’IE6′}{endif}
    {if IE 7}{span id=’IE7′}{endif}
    {if IE 8}{span id=’IE8′}{endif}
    {if IE}{/span}{endif}

    In my CSS-files, I can now keep all rules together, which is a lot more comfortable when developing and testing.

    #header{margin-top: 5px}
    #IE6 #header{margin-top: 7px}
    #IE7 #header{margin-top: 6px}

    With this system, I don’t need to rely on hacks anymore for any IE-version (e.g. !important).
    When revising stylesheets months or years later, I can quickly see where and what I fixed for which IE-version.

    I would have liked to make the body-tag conditionnal, but it gets messy sometimes working with content management systems, so I never bothered.

    I’m actually surprised that in 2010 a lot of developpers still work with separate cc-served stylesheets.

  18. On May 13, 2012, 11:09 CEST, scutterman said:

    I came here after searching for opinions on whether it’s a good idea to use CC stylesheets, and I believe that the way I’m using them isn’t completely against what is said here.

    I am currently working on a template for a site, and I needed to add in some hacks for inline-block for IE 7. I decided to add these hacks into a second stylesheet so that the compliant browsers wouldn’t have to deal with them, and also so that they don’t have to deal with the extra bytes in the file that they completely ignore.

    I will still have the problem that, if I decide to change the inline-block status of the selectors using it, I’ll have to make the changes in the CC sheet as well, but this seems like a minor price for not introducing hacks unless they are explicitly needed.

Read More

Have a look at the most popular posts, possibly including:

Or maybe say hi on Google+, Twitter, or LinkedIn?

Looking for a way to comment? Comments have been disabled, unfortunately.

Found a mistake? Reward! Email me,

You are here: HomeArchive2008 → To Be Clear (on Conditional Comments and Resets)

Last update: December 12, 2016.

“All education shall be free […].”