Html5-boilerplate: Revert back to `<!doctype html>` ?

Created on 22 Mar 2014  Β·  18Comments  Β·  Source: h5bp/html5-boilerplate

Previous discussions

Commit in which the change was made: https://github.com/h5bp/html5-boilerplate/commit/7a2f9dcf8b56b6923a5bde028ea1838d32572588
Relevant issues: #335, #1059.

Specification, browsers and validators

From WHATWG

A DOCTYPE must consist of the following components, in this order:

  1. A string that is an ASCII β†’ case-insensitive ← match for the string "
  2. One or more space characters.
  3. A string that is an ASCII β†’ case-insensitive ← match for the string "html".
  4. Optionally, a DOCTYPE legacy string or an obsolete permitted DOCTYPE string (defined below).
  5. Zero or more space characters.
  6. A U+003E GREATER-THAN SIGN character (>).

In other words, , case-insensitively.

So, according to the specification, the case doesn't matter. Also, browsers (AFAIK) don't really care, and the W3C validator is fine with either case.

Pros and cons for using <!doctype html>

Pros:

Cons:

  • some IDEs/text editors complain about the syntax (IMHO this shouldn't be a concern for H5BP, as it represents a bug in the IDE/text editor, and thus, it should be fixed by them. Going on this path, one can argue that we shouldn't use CSS3 features because some IDEs/text editors complain about the new syntax).
  • the uppercase form is more commonly used, and thus, it doesn't make developers wonder/curious.

Thoughts?

Most helpful comment

The compression of 'doctype' vs 'DOCTYPE' is never going to matter.

All 18 comments

I thought of this as soon as I read that compression article.

Note that the β€œcompresses better” argument is a generalization – it assumes that throughout the rest of the document, the lowercase document characters are more common than uppercase DOCUMENT characters. This may not be true for all documents.

β€œmay spark the developer's curiosity” is subjective – you could say the same thing about <!DoCtYpE hTmL>.

Another reason pro uppercase is polyglot/XHTML compatibility (although XHTML is not something anyone actively wants to support).

The compression of 'doctype' vs 'DOCTYPE' is never going to matter.

Having DOCTYPE uppercase will keep it consistent with its mentions in docs on WHATWG.

Having doctype lowercase will keep it consistent with @paulirish.

CHECKMATE checkmate.

I would be in favor of leaving the doctype as it is, in upper case. There is not a lot of value for any other variant.

@mathiasbynens I also think the uppercase variant has a slight advantage, as you said, probably not bc somebody wants to support polyglot/XHTML whatever =)...but any xml parser could parse a HTML document with an uppercase doctype while a lower or mixed case one would throw a parse error...not that a lot of people would extensively parse html documents with XML parsers (and also the rest of the tags should then be XHTML compatible, eg. self closing etc.) but who knows when you will, so I don't see anybody hurt due to an uppercase doctype but in the described case that would be possible...at least that's how I understood it =)

some IDEs/text editors complain about the syntax

Cant find evidence of this now, as I think it's been resolved.
Textmate 2: no problem. ST2: no problem. WebStorm 7: no problem. Atom: all good.

So given that, there are no serious reasons we would avoid lower-case.

H5BP rejected supporting polyglot documents a long time ago, it's not worthwhile to try to support it at doctype level and then ignore support for the rest.

I think the lowercase doctype is consistent with the lower-case of the html tags used. Beyond consistency, uppercase is loud, obnoxious and isn't a calm introduction into the HTML source. Google uses the lowercase doctype, along with hundreds of thousands of sites built with earlier h5bp versions.

@exside that would make it inconsistent with some of the other decisions made by h5bp. You mentioned self-closing tags, for example; h5bp does not have self-closing tags. If doctype should be uppercase for the purpose of being compatible with xml, then everything else should be xml compatible as well.

This isn't intended to say that there are zero reasons for using uppercase, only that the reason you've brought up is an invalid one, or at least inconsistent with some of the other decisions h5bp has made.

@QWp6t from that point of view, you're definitely right =)...i use my "own" crafted base template which for sure got a good amount of best practices form h5bp, so I didn't have that "pure" h5bp thing in mind when writing that comment, but I liked the strictness of XHTML somehow and thus I'm still writing in an XHTML compliant way (e.g. with self closing tags etc.)

What's the conclusion here? I still don't see reasons to change the doctype.

I still don't see reasons to change the doctype.

@drublic for me, the main reason for this change is that it feels more consistent with the rest of the code.

I think the lowercase doctype is consistent with the lower-case of the html tags used. Beyond consistency, uppercase is loud, obnoxious and isn't a calm introduction into the HTML source. Google uses the lowercase doctype, along with hundreds of thousands of sites built with earlier h5bp versions.

Considering the above comment from @paulirish I think I'll vote for the change.

@alrra Yes, I'm a _for_

I think the lowercase doctype is consistent with the lower-case of the html tags used.

And the other way around, the upper-case will differentiate DOCTYPE declaration string (preamble) from regular html tags.

My :+1: for <!DOCTYPE html>

Thank you all for your feedback!

If anyone is interested in some stats:

(:warning: please keep in mind that those numbers are not necessarily representative for actual pages with content, so treated them just as fun stats!)


404.html
  • 404.html using <!DOCTYPE html>

    original size:         1242 B
    gzipped size:           580 B
    ─────────────────────────────
    reduction:              662 B [53.3%]
    
  • 404.html using <!doctype html>

    original size:         1242 B
    gzipped size:           574 B
    ─────────────────────────────
    reduction:              668 B [53.8%]
    

index.html
  • index.html using <!DOCTYPE html>

    original size:         1760 B
    gzipped size:           879 B
    ─────────────────────────────
    reduction:              881 B [50.1%]
    
  • index.html using <!doctype html>

    original size:         1760 B
    gzipped size:           875 B
    ─────────────────────────────
    reduction:              885 B [50.3%]
    

I just realized I should have just voted with my tech twitter background image
4-3-2014 11-02-46 am

Was this page helpful?
0 / 5 - 0 ratings