molly.com

Saturday 31 July 2004

DOCTYPES not relevant?

PERHAPS IT WAS just his choice of words that caught my concern, but in a recent comment, Anne van Kesteren claims that “. . . a DOCTYPE isn’t really relevant” [1]. For the theoretician, perhaps this is true. For the practitioner, the relevance is indisputable.

First, a few things about DOCTYPEs in HTML and XHTML for those unfamiliar:

  • DOCTYPE declarations are that bit of SGML syntax that should be at the top of every HTML or XHTML document you author – they define the document type and provide a URI to the document’s DTD (Document Type Definition)
  • Beyond declaring the document’s type, DOCTYPE declarations come into play when the document is validated. The validator uses the information in the declaration to compare against the DTD and report any warnings or errors
  • DOCTYPE declarations are required in conforming HTML or XHTML documents

Nowadays, DOCTYPE declarations also provide us with an incredibly important tool: The DOCTYPE Switch. Having a correctly formed DOCTYPE will cause browsers to run in compliance mode – an optimal browser mode for standard, conforming documents.

DOCTYPE switching is of course a debate in and of itself. That a piece of code used to identify and validate a document is being made into a functional part of the browser is considered a browser hack by many. I see the rationale behind that point, I do. But right now I’m more concerned with the benefit that switch provides to the working designer and developer.

Where DOCTYPE switching becomes crucial to the working developer is when designing with CSS layouts. That dominant bitch of a browser, Microsoft Internet Explorer 6.0 for Windows, has several CSS flaws, and one of the most challenging is that its native implementation of the Box Model conforms to the Microsoft interpretation, not the W3C specs. But what many don’t realize is that by using a DOCTYPE declaration that invokes switching, IE 6.0 will switch over into compliance mode where, guess what? You get the W3C interpretation of the box model, solving a significant concern with CSS design.

While the DOCTYPE switch might be seen as some to be a hack itself, is using a proper DOCTYPE declaration required by the specs in the first place a hack? All we’re doing in that scenario is what we’re supposed to be doing anyway, even if there’s the added advantage of solving a serious concern.

The other alternatives available to us are to add hacks and filters into the CSS, fall back on transitional techniques for layout, or look to the CSS3 box-sizing property, which has very limited support because CSS3 isn’t even a recommendation yet! If your target browser base doesn’t include IE browsers below 6.0 and you’re implementing switching, you might not have to add a hack or filter anywhere in your CSS. So in that scenario, you’re following the specs and not hacking to get the correct results.

Is the DOCTYPE debate one of what is ideal versus what is real? Perhaps, but practicality has to rule the day, at least during this very difficult, transitional time where people desperately want to reap the benefits of compliant design. This, despite the fact that the major stumbling block is one primary piece of software, IE 6.0, which also happens to be the most widespread, flawed software that we have to deal with. To my way of thinking, this makes DOCTYPEs extremely relevant, whether we like it or not.

Filed under:   general
Posted by:   Molly | 06:10 | Comments (39)

Comments (39)

  1. Pingback: MIME types matter; DOCTYPEs don't <Anne's Weblog about Markup & Style>

  2. Pingback: Koodaus.net Blog - DOCTYPE:n merkitys

  3. 🙂

    What I meant was, and I was actually just writing up something for my own weblog on this very subject, that DOCTYPES don’t make the distinction between HTML and XHTML, but MIME types do.

    Read Re: Sniffing XHTML sent as text/html for some explanation and I will try to pingback this post as well, for a more detailed one.

    By the way, I agree with most of what you write here, perhaps you took it out of the context too much. And of course, I wasn’t very clear myself.

  4. Anne: no worries, not a personal slight meant – anything for the sake of education. As I mentioned, it was likely the wording that grabbed my attention. Looking forward to the pingback, and ultimately – all readers benefit from these exchanges. 🙂

  5. DOCTYPE switching is only relevant to documents served as text/html. If you are serving an XHTML document, and serving it with an XML MIME-type (like application/xhtml+xml), then it will be treated identically, whether or not it has a DOCTYPE declaration.

  6. Jacques:

    While you are entirely right, that statement has little use to people that have to deal with this situation today, rather than 5 years from now. Sending the XHTML MIME-type will keep Internet Explorer from rendering the page (and force it into asking the user if s?he wants to “Save this file”). So any web author is then left with this choice:

    A) prevent ALL Interet Explorer users from ever seeing my pages
    OR
    B) serve up true XHTML to compliant browsers only and give text/html to IE-users
    OR
    C) don’t bother with server-side sniffing and just send without a specific MIME-type and let the browser handle the page on its own (which generally leads Mozilla etc. to consider it XHTML, and IE to render it as text/html)

    With the situation being as it is today, nearly all people will go for option B or C, but since neither B nor C are the “wrong” choice here (nor is A, for that matter), it’s hard for others, who are only just getting into this area, to make a decision at all (and stick to it).

    The problem lies not in the W3 specs being too vague (like with the whole Headings/Hierarchy issue of a little while ago), but in the fact that it can’t possibly be implemented in any consistant manner. Unless, of course, you really do want to block all IE-users access…

  7. Faruk,

    I’m well aware of the pitfalls of serving application/xhtml_xml. I’ve been doing that for over a year and a half. I do so for a reason: XHTML+MathML content.

    But you are wrong about “C)”. Anything sent as text/html is handled by the tag-soup (HTML) parser in every browser. If I want my content handled by the XML parser (say, for a Firefox or IE6+MathPlayer2.0 user), it is necessary to send it with an XML MIME type. It matters not a whit what DOCTYPE it sports.

  8. Jacques,

    Ah right, Mozilla was told by the W3C to treat anything sent as text/html as HTML (even when the DOCTYPE specifies XHTML) – you’re very right on correcting me on that, thanks. 🙂

    But the point still stands that present-day environments prevent anyone from being able to be fully in the right with one particular method, here. Sadly…

  9. Mozilla was told by the W3C to treat anything sent as text/html as HTML (even when the DOCTYPE specifies XHTML)

    It’s more than just “The W3C said so.”

    I had some extensive discussions with the folks from DesignScience when they were working on their MathPlayer 2.0 plugin (for IE/6). They decided (quite independently of the W3C, I should add) to implement their MathML support only for documents served with an XHTML MIME type. That way, they could be assured that they only had to deal with well-formed content (making their job much easier). [Added bonus: with the plugin installed (I understand it is bundled with Encarta.), IE/6 supports application/xhtml+xml.]

    A similar decision was made by the folks who did the MathML support (and Ruby support and native SVG support) in Gecko. In all these cases, if you want cool new features you need to use an XHTML MIME type.

  10. What is this miraculous trick that allows IE to render CSS properly? (It’s not some complicated round about is it?). Link PLEASE.

  11. Pingback: Milan Negovan

  12. Jason: it’s not really a trick that makes IE6 render CSS properly. However, if you put a doctype declaration at the top of your HTML document (with nothing else before it), IE6 will use the W3C box-model (just like Mozilla and, I think, Opera do) for determining the relationship between an element’s padding, border and width.

    Bit of an old article on doctypes here, might help you:

    http://www.oreillynet.com/pub/a/network/2000/04/14/doctype/index.html

  13. Even if Internet Explorer will render a page closer to the W3C specifications when it is in standard mode (and not quirk mode), Internet Explorer still is lightyears away from a proper box model.

    What differs standard mode from quirk mode in Internet Explorer (and other browsers, like Opera an Mozilla, that mimic this behaviour) is how the CSS (and HTML) is interpreted. More errors made by the author is accepted, like missing units designators and such.

    In quirk mode, Internet Explorer “helps” the author by applying a lot of default values when they are missing from the CSS document, and these default values are what’s missing in standard mode.

    If you’re in quirk or standard mode, Internet Explorer will still render a CSS box wrong, because it interprets the ‘width’ as the outer width of a box, while the CSS specification says that ‘width’ applies to the ‘content width’. The total width of a box is the content width, plus its right and left padding, plus its right and left margin plus the width of the right and left borders.

  14. Asbjørn, I think you may be incorrect there. I’m currently building a site using the XHTML transitional doctype to throw IE6 into “standards mode”, and it does in fact follow the correct box model. This only works for IE6, not previous versions – but writing a primary stylesheet for IE6 and all other compliant browsers, and an additional “hacks” stylesheet for older versions of IE served up between conditional comments works pretty well for me.

  15. Like your site Molly! Also, always liked your articles in Web Techniques…I have a massive stack of those I reread from time to time stacked up in my magazine rack!

    On the IE box model, a couple corrections…yes, IE 6 “fixes” allot of issues that IE 4-5.5 had in the so-called box model where padding and border valus are incorrectly incorporated in the width value, for example. It appears that IE 6 only corrects that in “standards” mode using one of several DOCTYPES. It also seems as though in quirksmode, it reverts to IE 5.5 box model useage, which is strange. IE 6 as well as previous versions also suffer from a whole host of other issues, varying by OS and version, and some of which continue to exhist in standards mode in IE 6. Go here to have a good laugh (and frustrated sigh) at the real complexity of the problem: http://www.positioniseverything.net/index.php
    My recommendation for solving the doctype problem is simple, though: just pick a “mode” and design for it. Be consistent through your site and you will do fine. Theer are plenty of people who actually voluntarily refuse to design for standards and as long as they leave out the doctype and rely on quirks interpreation by the browser, for the most part they are good. Its a voluntary decision. Of course, in my opinion thats foolish as there are WAY more problems relying on browsers to support your sloppy code reliably. But again, look at the complexity of patched solutions we are quickly stuck with in CSS and all the named hacks out there. So, pick your poison, I guess – Mitchell

  16. Pingback: Web Standards Project BUZZ

  17. Pingback: Koodaus.net Blog

  18. I don’t know how well everyone will take this (since it is a little off topic), but I’m a little tired of all this IE bashing.

    Granted it doesn’t support standards correctly, but everyone is forgetting one major detail. IE6 was released in the beginning of 2002, right toward the end of the browser wars and just when designers started to realize the true power of web standards and CSS based design. Not to mention IE 5.5 which was released in 2001 (Almost 4 years is a long time ago, especially for software relating to the ever changing internet).

    Mozilla and the rest support standards so well because they come out with new versions almost monthly. The last major revision of IE to be released was almost two years ago (aside from all the security patches). If IE’s rendering engine was updated as often as Mozilla was, I doubt anyone would have a problem with it.

    Sorry for the rant, but I’m starting to get sick of every article on web design devoting at least a paragraph of space about how IE sucks.

  19. I too get a bit tired of the IE smashing, especially when it comes to the box model. I see a lot of things like ,incorrect use, wrong box-model, so-called boxmodel.. but to me, the box model used by IE makes far more sense than the one specified by w3c. Easy example. Suppose I want 1 element with a 100% width and 10px padding. According to the w3c this gives me a horizontal scrollbar, cause the padding is added to the 100% width. There is no logic at all to this approach, padding should be incorporated in the width and if u ask me the w3c is wrong here, not IE.

  20. As if it have _ever_ mattered “what makes sense” when it comes to following standards. Internet Explorer doesn’t follow standards, and thus it sucks. Its rendering engine hasn’t been touched in good over two years, which makes it suck even more.

    If Sony would ship a radio that couldn’t decode FM signals correctly, and by doing that underscored it with “you see, we think our FM model is better!”, would that be okay? And what if this radio was pre-installed in all sold houses in the world the next couple of years, and Sony still hadn’t done anything about their standard-breaking radio? Would that be okay?

    What if someone found out that because of this bug, or because of other bugs in the radio Sony also chose not to fix, made it possible to destroy property in the houses of people, and Sony used two or maybe three months to fix it? Would that be okay?

    This analogy is taken a bit to the extreme, but it is done to show that supporting standards isn’t something special and something one can just ignore because we’re talking IT jargon. Standards are what makes the wheels go around in our society, ranging from the stoves we easilly can guarantee to be able to fit into our kitchens, to the gazoline we fill on our cars, to the CD’s we listen to on our stereo sets.

    If a company decides to break a standard, it’s never okay. If that company has a 90% or more market share, it’s even less okay, because that makes it hard or even impossible for others to compete in the same market. It would be interesting to know how many months of work Opera Software and the Mozilla Foundation have spent to reproduce Internet Explorer’s bugs in their browsers.

  21. Ok… I see your point. If no one ever breaks standards, however, what happens to innovation and progress? If we all follow blindly and do what the rules say and only what the rules say, there will never be any new technologies. The reason why we still use gasoline today is because of companies that impose their presence on the market, as I assume you imply Microsoft does. There are plenty of acceptible alternative fuel sources just waiting to be developed that are cheaper and more efficient than gasoline, but the cartels engage in even worse shifty and unethical business practices than just taking advantage of a large market share.

    Contrary to what you say, I think it IS okay to break standards. If someone comes up with a better idea than the one that is currently supported, why not? The box model as stated by Jurrian above is a perfect example. Microsoft felt that their box model implementation was better (and I believe it is also… even Zeldman says this, somewhat, in his book “Designing with Web Standards”). The problem with Microsoft’s box model was that designers were too caught up with following the standards made by the W3C that they were blind to a way of doing things that is actually more intuitive. In fact, if I understand correctly, CSS3’s box model will implement a way to choose how to render boxes, either by the current standard, or by Microsoft’s quirks mode method. Now if Microsoft hadn’t taken the chance and broke the standard, the Box Model would never have been ammended in that way. If the current box model is so superior, then why is the W3C even considering implementing Microsoft’s way of rendering the box model?

    Breaking standards drives innovation, plain and simple.

  22. no, breaking standards drives frustration, not innovation. Especially on something as important and pervasive as a browser in today’s world.

  23. “Now if Microsoft hadn’t taken the chance and broke the standard, the Box Model would never have been ammended in that way. If the current box model is so superior, then why is the W3C even considering implementing Microsoft’s way of rendering the box model?”
    ————–

    Probably because it has the overwhelming majority market share IE has. Microsoft’s virtual monopoly in the browser space (and therefore the sheer amount of questionably-coded pages that rely on it) is too high for the w3c to ignore in the shaping of future recommendations. All speculation, of course. I know nothing about CSS3, so I’m not sure what’s going on in that area.

  24. If no one ever breaks standards, however, what happens to innovation and progress?

    This is an often used argument for allowing standard breakage, and it was used just lately when Apple broke HTML when introducing their own elements and attributes. However, Apple’s intent all along, afaik was that these new elements and attributes were going to be incorporated in a standard, and the most likely (pseudo) standards body to implement it, is WHAT WG.

    So, innovativity is in no way killed by standardization, it just takes a bit more time and cooperation. But the result is that everyone can deploy the innovative new technology, and everyone can comment on it and improve it before it reaches its final status.

    The reason why we still use gasoline today is because of companies that impose their presence on the market, as I assume you imply Microsoft does.

    No, that’s not what I meant. What I tried to illustrate, was that if you came to a gas station that said they sold «95 octane lead-free» and got something completely different, or even something slightly different, your car would break. This is exactly what Microsoft do. They’ve implemented CSS2 so half-assed that it’s impossible to develop for it by following the standards, and even worse: they haven’t documented the descrepancy either.

    Contrary to what you say, I think it IS okay to break standards. If someone comes up with a better idea than the one that is currently supported, why not?

    It is just fine to come up with a new idea, but then it is just that: a *new* idea. Implementing a 1/4 of CSS2 by the book, the next 1/4 by «what we think is best» and leaving the rest 1/2 out, is not okay. What Microsoft should have done, was either to not implement CSS2 at all, implement the parts they could be finished with correctly, or created their own stylesheet language.

    It would be a lot better to have MS-CSS as an orthogonal «standard» to CSS2, since then it would be a clear line between what was intended for Internet Explorer and what wasn’t. Supporting Microsoft’s box model would then be prefectly fine, since their box model was defined in their own stylesheet language, which couldn’t break the box model of CSS2, because Internet Explorer didn’t understand anything of CSS2.

    Now, I don’t say that creating your own stylesheet language is a good idea. What I would really like, was if Internet Explorer supported CSS2 by the book. But it doesn’t. And that isn’t because of innovativity and genious minds in Microsoft thinking «hey, this should be like that, because it works better this way!», but because the CSS2 specification isn’t read thorough enough.

    Just briefly browsing through CSS2 could of course make it appear that the box model is supposed to be the way Microsoft has implemented it. I agree that it makes most sense. It’s most intuitive. However, that’s not how it is defined, so whatever Microsoft have done that deviates from it, is plain out wrong. No excuses. If Microsoft had continued to develop Internet Explorer instead of leaving it out to rot for a couple of years, I’m confident that they could either have made the box model work, or communicated inside the W3C to change it, in *cooperation* with e.g. Opera and Mozilla.

    Breaking a standard is never right. Either you follow it strictly and by the fibers, or you don’t follow it at all.

  25. If no one ever breaks standards, however, what happens to innovation and progress?

    This is an often used argument for allowing standard breakage, and it was used just lately when Apple broke HTML when introducing their own elements and attributes. However, Apple’s intent all along, afaik was that these new elements and attributes were going to be incorporated in a standard, and the most likely (pseudo) standards body to implement it, is WHAT WG.

    So, innovativity is in no way killed by standardization, it just takes a bit more time and cooperation. But the result is that everyone can deploy the innovative new technology, and everyone can comment on it and improve it before it reaches its final status.

  26. The reason why we still use gasoline today is because of companies that impose their presence on the market, as I assume you imply Microsoft does.

    No, that’s not what I meant. What I tried to illustrate, was that if you came to a gas station that said they sold «95 octane lead-free» and got something completely different, or even something slightly different, your car would break. This is exactly what Microsoft do. They’ve implemented CSS2 so half-assed that it’s impossible to develop for it by following the standards, and even worse: they haven’t documented the descrepancy either.

  27. Contrary to what you say, I think it IS okay to break standards. If someone comes up with a better idea than the one that is currently supported, why not?

    It is just fine to come up with a new idea, but then it is just that: a *new* idea. Implementing a 1/4 of CSS2 by the book, the next 1/4 by «what we think is best» and leaving the rest 1/2 out, is not okay. What Microsoft should have done, was either to not implement CSS2 at all, implement the parts they could be finished with correctly, or created their own stylesheet language.

    It would be a lot better to have MS-CSS as an orthogonal «standard» to CSS2, since then it would be a clear line between what was intended for Internet Explorer and what wasn’t. Supporting Microsoft’s box model would then be prefectly fine, since their box model was defined in their own stylesheet language, which couldn’t break the box model of CSS2, because Internet Explorer didn’t understand anything of CSS2.

    Now, I don’t say that creating your own stylesheet language is a good idea. What I would really like, was if Internet Explorer supported CSS2 by the book. But it doesn’t. And that isn’t because of innovativity and genious minds in Microsoft thinking «hey, this should be like that, because it works better this way!», but because the CSS2 specification isn’t read thorough enough.

    Just briefly browsing through CSS2 could of course make it appear that the box model is supposed to be the way Microsoft has implemented it. I agree that it makes most sense. It’s most intuitive. However, that’s not how it is defined, so whatever Microsoft have done that deviates from it, is plain out wrong. No excuses. If Microsoft had continued to develop Internet Explorer instead of leaving it out to rot for a couple of years, I’m confident that they could either have made the box model work, or communicated inside the W3C to change it, in *cooperation* with e.g. Opera and Mozilla.

    Breaking a standard is never right. Either you follow it strictly and by the fibers, or you don’t follow it at all.

  28. Just briefly browsing through CSS2 could of course make it appear that the box model is supposed to be the way Microsoft has implemented it. I agree that it makes most sense. It’s most intuitive. However, that’s not how it is defined, so whatever Microsoft have done that deviates from it, is plain out wrong.

    if the facts don’t fit the theory, change the theory to fit the fact. If u say urself one way is better, than the standard should be changed. Of course, that would be a bit of a problem with a standard, but it should not have hold them back by dealing with the whole box-modelling issue by creating a innerWidth (just width according to w3c) and outerWidth (width + padding + border + margin). This could have been implemented years ago, but instead the w3c holds on to a method that is counter-intuitive and a cumbersome problem, to me at least.

    I recently read a quote from a designer of ECMAScript 4 on post-colon syntax for datatyping (var s:String = “bla”; supposed to be used in Javascript 2):

    Why Post-Colon Syntax?
    Embarrissingly, this is a decission based purely on a historical standards committee vote – this seemed like a good idea at one time. There is no technical reason for using post-colon syntax, but its too late to reverse it now (implementations using this syntax have allready shipped), even though most of the people involved with it admit the syntax is a mistake.

    Than I think.. how can such a thing become a standard, while there are still such mistakes in it. Same for w3c.. pretty much seems the box-model wasn’t thought through long enough and they can’t change it now, cause hey.. it’s allready a standard. For me it would make much sense if a language designer, using the ECMAScript4 Standard for syntax design, will still choose the more normal Java, C++ way for datatyping.

  29. Okay, Internet Explorer’s box model probably makes more sense. I can admit that. Breaking the CSS standard because you don’t like it is still pretty damned braindead.

  30. What about the concept that IE allows anyone to post an idea on the web.Anyone can put some html together and post it. The web was supposed to democraticize the world, but standards are hard to learn and it excludes people. Is that ok?

  31. Pingback: Grafika No. 2 » Blog Archive » HTML Vs XHTML

  32. The true problem with the w3c box model is that border widths can’t be defined with percentual values and that we tend to forget that there is a margin and a padding pre defined by the ua. Otherwise is a lot better. I prefer to know that my content width + border width+padding width+margin width equals the content of the parent box wich might have those widths defined or not.
    Alas in the ie box model we need to figure out what space was left for the content afer we aplied the sorrounding box.

  33. Just a semantic point…

    The ‘non-quirks’ mode is referred to as “standards mode” rather than “compliance mode”.

    That may seem trivial, accept that browsers do not comply with mandated standards; rather, they ‘conform’ to recommended stanards. “Conformant mode” may be a more accepatable alternative.

  34. I had a dream where I was running up into the sky, almost like flying. There where others beside me, behind me and in front of me. All of us where headed in the same direction. I guess the objective was to climb the skies, climb until we got to the very top (Heaven?). It was almost like a race to reach the top. Finally I reach the end of the skies, there is a white wall, I and others touch it and then people begin to free fall back down to earth. I watch others willingly fall, they look happy to do so. I fall with them, it feels like I fall for but a second. I can feel the wind rush past me and I’m aware of the weightlessness of my body as I fall to the ground. Talk about having a weird dream.

  35. a good boat site are

    Boot und Yacht Forum

Upcoming Travels