Difference between revisions of "Document type declaration"

From Wiki @ Karl Jones dot com
Jump to: navigation, search
(External Links)
(See also)
 
Line 14: Line 14:
  
 
The DOCTYPE is retained in HTML5 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers.
 
The DOCTYPE is retained in HTML5 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers.
 +
 +
== Syntax ==
 +
 +
The general syntax for a document type declaration is:
 +
 +
<pre>
 +
&lt;!DOCTYPE root-element PUBLIC "FPI" ["URI"] [
 +
&lt;!-- internal subset declarations --&gt;
 +
]&gt;
 +
</pre>
 +
 +
or
 +
 +
<pre>
 +
&lt;!DOCTYPE root-element SYSTEM "URI" [
 +
&lt;!-- internal subset declarations --&gt;
 +
]&gt;
 +
</pre>
  
 
== See also ==
 
== See also ==
Line 24: Line 42:
 
* [[SGML]]
 
* [[SGML]]
 
* [[XHTML]]
 
* [[XHTML]]
* [[XML]]  
+
* [[XML]]
  
 
== External Links ==
 
== External Links ==

Latest revision as of 04:47, 15 May 2016

A document type declaration, or DOCTYPE, is an instruction that associates a particular SGML or XML document (for example, a web page) with a document type definition (DTD) (for example, the formal definition of a particular version of HTML).

Description

In the serialized form of the document, it manifests as a short string of markup that conforms to a particular syntax.

The HTML layout engines in modern web browsers perform DOCTYPE "sniffing" or "switching", wherein the DOCTYPE in a document served as text/html determines a layout mode, such as "quirks mode" or "standards mode".

Since web browsers are implemented with special-purpose HTML parsers, rather than general-purpose DTD-based parsers, they don't use DTDs and will never access them even if a URL is provided.

HTML5

The text/html serialization of HTML5, which is not SGML-based, uses the DOCTYPE only for mode selection.

The DOCTYPE is retained in HTML5 as a "mostly useless, but required" header only to trigger "standards mode" in common browsers.

Syntax

The general syntax for a document type declaration is:

<!DOCTYPE root-element PUBLIC "FPI" ["URI"] [ 
<!-- internal subset declarations -->
]>

or

<!DOCTYPE root-element SYSTEM "URI" [ 
<!-- internal subset declarations -->
]>

See also

External Links