Uppercase or Lowercase Doctype

Uppercase or lowercase doctype?

In HTML, the DOCTYPE is case insensitive. The following DOCTYPEs are all valid:

<!doctype html>
<!DOCTYPE html>
<!DOCTYPE HTML>
<!DoCtYpE hTmL>

In XML serializations (i.e. XHTML) the DOCTYPE is not required, but if you use it, DOCTYPE should be uppercase:

<!DOCTYPE html>

See The XML serialization of HTML5, aka ‘XHTML5’:

Note that if you don’t uppercase DOCTYPE in an XHTML document, the XML parser will return a syntax error.

The second part can be written in lowercase (html), uppercase (HTML) or even mixed case (hTmL) — it will still work. However, to conform to the Polyglot Markup Guidelines for HTML-Compatible XHTML Documents, it should be written in lowercase.

Why !DOCTYPE and not !doctype ?

It's just a convention that we do uppercase. The spec says that it's case-insensitive.

In other words, <!DOCTYPE html>, case-insensitively.

Why !DOCTYPE and not !doctype ?

It's just a convention that we do uppercase. The spec says that it's case-insensitive.

In other words, <!DOCTYPE html>, case-insensitively.

What is the meaning of public= storage in the HTML doctype?

Someone else posted this in an answer but deleted it for some reason. It is apparently a joke by the author of that document — who, in a comment on a GitHub issue, links to a number of other instances of this oddity within the same project. As Quentin comments,

I suspect this falls under the category of "None of the tools we use care about what comes after the 'html' bit of the Doctype, let's just shove our extendo-crap in there"

What you see is not valid DOCTYPE syntax. The formal public identifier follows the PUBLIC keyword separated by optional whitespace, not an equals sign. The other examples linked to by the author of the document don't seem to have an equals sign like this one does, but as mentioned it doesn't make any difference anyways.

As for case sensitivity, DOCTYPE declarations are only case-sensitive in XML.

Is HTML case sensitive?

No, but it's considered good practice to keep HTML markup lowercase.

What are HTTP 'method' capitalization best practices?

The HTML5 spec requires to use "get" or "post".

Questions about Doctype

This is probably because you are using elements that are associated with a specific DOCTYPE. <!DOCTYPE html> defaults to html5. If no DOCTYPE is specified, you webpage defaults to quirks mode. Since you set everything up according to this standard, it isn't compatible with a standard mode.



Related Topics



Leave a reply



Submit