Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Lets take a look at the W3C HTML5 definition, they have a conveniënt page about the differences HTML5 brings: <a href="http://www.w3.org/TR/html5-diff/#doctype" rel="nofollow">http://www.w3.org/TR/html5-diff/#doctype</a></p> <blockquote> <p>2.2 The Doctype</p> <p>The HTML syntax of HTML5 requires a doctype to be specified to ensure that the browser renders the page in standards mode. The doctype has no other purpose. [DOCTYPE]</p> <p>The doctype declaration for the HTML syntax is and is case-insensitive. Doctypes from earlier versions of HTML were longer because the HTML language was SGML-based and therefore required a reference to a DTD. <strong>With HTML5 this is no longer the case</strong> and the doctype is only needed to enable standards mode for documents written using the HTML syntax. Browsers already do this for .</p> <p>To support legacy markup generators that cannot generate the preferred short doctype, the doctype is allowed in the HTML syntax.</p> <p>The strict doctypes for HTML 4.0, HTML 4.01, XHTML 1.0 as well as XHTML 1.1 are also allowed (but are discouraged) in the HTML syntax.</p> <p>In the <strong>XML syntax</strong>, any doctype declaration may be used, or it <strong>may be omitted altogether</strong>. Documents with an XML media type <strong>are always handled in standards mode</strong>.</p> </blockquote> <p>On that page, chapter 1 (Introduction) says more about HTML versus XML syntax:</p> <blockquote> <p>The HTML5 draft (..) defines a single language called HTML which can be written in <strong>HTML</strong> syntax and in <strong>XML</strong> syntax.</p> </blockquote> <p>So, if your HTML5 is strict XML syntax, i can conclude from the last paragraph that yes in this case you should not prefix a doctype line.</p> <p>See chapter 2 for the difference in syntax:</p> <p>HTML5 <strong>HTML</strong> syntax:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Example document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Example paragraph&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>HTML5 <strong>XML</strong> syntax:</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;Example document&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;p&gt;Example paragraph&lt;/p&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>There is some subtle differences in syntax.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload