Add Site or Add Page to Favorites
 

 DOCTYPE Declaration 

Clarify the meaning of the acronyms on your web site.

Acronym Dictionary

Acronym Finder

Get information on your favorite TV Shows at TV Series .com

Social Networking Web Sites


Printer-friendly PDF* format:

DOCTYPE Declaration

The DOCTYPE Declaration

The DOCTYPE declaration in HTML 5

The DOCTYPE declaration indicates that the content is a HTML document. The name parameter of the DOCTYPE declaration must be html, matching the name of the top element an HTML document.

Converting to HTML 5

We are working on converting to HTML 5. Please visit HTML DOCTYPE Declaration on the HTML 5 standard version of this site.

HTML Best Practices - Why specify a doctype?

From the W3C Tips for Webmasters:

Why specify a DOCTYPE? Because it defines which version of (X)HTML your document is actually using, and this is a critical piece of information needed by browsers or other tools processing the document.

Since the document type is needed by web browsers, viewers or other tools in order to properly interpret a document as a particular version of HTML, the information provided by the DOCTYPE is especially important in situations where there are no HTTP headers available or when the headers do not indicate an XHTML/XML media type such as application/xhtml+xml. Therefore, the DOCTYPE declaration is an important element when creating polyglot HTML documents.

<!DOCTYPE> Declaration Syntax

Syntax of the DOCTYPE declaration for HTML 5

                                 <!DOCTYPE html>
                                 

<! indicates that this is an SGML declaration, DOCTYPE indicates the type of declaration is for the document type, html is the tag name of the top element of the document and > ends the declaration.

Attributes of the DOCTYPE Declaration

Attributes of the DOCTYPE Declaration

attribute
The attribute
HTML 5 Examples

Examples of the DOCTYPE declaration in HTML 5

DOCTYPE with no additional entity declarations

                                 <?xml version="1.0" encoding="UTF-8"?>
                                 
<?xml-stylesheet type="text/xsl" href="/site-template.xsl"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
...
</html>

DOCTYPE with entities defined in an internal subset

                                 <?xml version="1.0" encoding="UTF-8"?>
                                 
<?xml-stylesheet type="text/xsl" href="/site-template.xsl"?>
<!DOCTYPE html [
    <!ENTITY nbsp "&#160;">
]>
<html xmlns="http://www.w3.org/1999/xhtml">
...
</html>

If the HTML is being produced by software that does not allow the DTD to be omitted, the URI about:legacy-compat may be specified:

                                 <!DOCTYPE html SYSTEM "about:legacy-compat">
                                 
Changes in HTML 5

What's new in HTML 5

There is no DTD for HTML 5. Therefore, the DOCTYPE declaration should not contain a PUBLICFPI or SYSTEM identifier. If the SYSTEM identifier is specified, the value should always be about:legacy-compat.

Differences between HTML 5 and earlier versions

The DOCTYPE declaration was introduced for validation of SGML documents and carried over to HTML, which uses markup tags similar to SGML. In SGML, XML and earlier versions of HTML, the DOCTYPE declaration points to a DTD, which describes the syntax that the markup language adheres to. Web browsers, which internally implement a rendering engine specific to HTML rather than relying on an external DTD, have used the document type declaration simply to determine how close to a supposedly standard version of HTML is being used. For that reason, the references to the DTD have been dropped from the DOCTYPE, but it is still included to indicate the HTML version.

A few legacy values in the DOCTYPE declaration are permitted, but obsolete. The PUBLIC and SYSTEM DTD identifiers should be removed from these declarations:

                                 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
                                 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

HTML pages with these DOCTYPEs may be interpreted as either one of the older (1997, 1999, 2000 or 2001, respectively) versions of HTML or as HTML 5, depending on the browser implementation. Once the PUBLIC, FPI and DTD identifier have been removed, the pages should only be interpreted as HTML 5 documents.

Last updated Sunday September 19, 2010

You are currently viewing this page in HTML 5 non-XML* format (* see Clicklets for more infomation). This document is also available in XHTML 1 Style Sheet*XHTML 1* XML*HTML 5 Style Sheet*HTML 5 XML*HTML 4* XHTML Mobile* WML Mobile* and printer-friendly PDF* formats. This is accomplished with Single Source Publishing, a content management system that uses templates in XSLT style sheets provided by XML Styles .com to transform the source content for various content delivery channels. There is also RDF* metadata that describes the content of this document.


Copyright © 2010 Accilent® Corp. Alteration of content, including addition of any function such as hypertext links or pop-up advertising, or interference with the hypertext links or other functions of this site is expressly prohibited.

DISCLAIMER: All information, links, forms, applications and other items on this site or obtained from it are provided AS IS, WITHOUT WARRANTY OF ANY KIND EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.