Problem
What is the proper approach for writing an HTML5 doctype?
<!DOCTYPE html>
or
<!doctype html>
Asked by joshnh
Solution #1
The DOCTYPE attribute in HTML is case-insensitive. All of the DOCTYPEs listed below are valid:
<!doctype html>
<!DOCTYPE html>
<!DOCTYPE HTML>
<!DoCtYpE hTmL>
The DOCTYPE attribute is not necessary in XML serializations (i.e. XHTML), however if it is used, it should be capitalized:
<!DOCTYPE html>
See HTML5’s XML serialisation, often known as ‘XHTML5’:
Answered by Mathias Bynens
Solution #2
If you’re still unsure in 2014, here’s what you should do:
HTML5
Doctype – W3 HTML5 Spec
The standard indicates that it is insensitive, despite the fact that it is shown in all uppercase.
XHTML5
HTML5 – XHTML (W3C)
DOCTYPE is specified in caps in the XML spec, but I can’t locate anything that says ‘all caps’ is required (for comparison, in the HTML5 spec listed above, it is displayed in the example in all caps, but the spec explicitly states that is is case-insensitive).
Polyglot Markup
Intro to W3 Polyglot Markup
Doctype – W3 Polyglot Markup
As a result, Polyglot Markup employs a standard HTML5 doctype with modifications. Most importantly, DOCTYPE is expressed in all caps, which is relevant to our issue.
Summary
See the W3’s HTML vs. XHTML section for further information.
[Opinion] Unless you’re expressly trying to make XML compliance considerations, I wouldn’t worry too much about it. For most client and JS-based server development, JSON has replaced XML.
As a result, I can only imagine this being useful if you’re trying to integrate new HTML5 features into an old XHTML/XML-based legacy system. Look into the polyglot markup spec if this is the case.
Answered by ucsarge
Solution #3
According to the most recent specification, you should use a case-insensitive match for!DOCTYPE html>. While browsers must support any case you like, it’s reasonable to conclude that!DOCTYPE html> is the canonical case.
Answered by John Mellor
Solution #4
It doesn’t matter if you use upper or lower case. However, if you use web fonts and care about IE7, I’d recommend using!DOCTYPE html> instead of!DOCTYPE html> because IE7 has a flaw that causes web fonts to fail sometimes when using!doctype html> (e.g. in this answer).
This is why the doctype is always capitalized.
Answered by jpw
Solution #5
Tags in HTML5 are case insensitive, according to the standard.
http://www.w3schools.com/html5/tag_doctype.asp
More Technically: (http://www.w3.org/TR/html5/syntax.html)
The following elements, in this order, must be included in a DOCTYPE:
Answered by Stephen
Post is based on https://stackoverflow.com/questions/7020961/uppercase-or-lowercase-doctype