HTML 5 DTD and DOCTYPE

 

ATTENTION: THIS PAGE IS Valid HTML 5 AND IS BEST VIEWED WITH HTML 5 - Please upgrade your browser or download one of the HTML 5 compatible browsers such as Mozilla Firefox, Chrome, Opera or IE 9 (March 14, 2011 or later). For more information see HTML 5 browsers.


If you find this helpful, please click the Google +1 Button to the left, if it is white, to make it turn blue or red. Thank you! (It also helps find this page again more easily.)


PDF mobile

DOCTYPE for HTML 5 - no HTML DTD

In the new HTML DOCTYPE, there is no Document Type Definition

HTML version 5 has no DTD. However, while the <!DOCTYPE> declaration could be omitted in previous versions of HTML, it is required to indicate to browsers that the document is using HTML version 5, at least for the HTML syntax. It is allowable, and in fact recommended that it be included for any HTML 5 document.

Since there is no HTML 5 DTD, no PUBLIC identifier or SYSTEM identifier appears in the declaration, which is simply <!DOCTYPE html>.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
   ...
</html>

In HTML 5, there is no transitional DOCTYPE, which allowed deprecated presentational elements to be included in the HTML code. In previous versions of HTML the separation of content from presentation using the strict DOCTYPE with style sheets was optional. Going forward, web developers should always use style sheets.

The new <!DOCTYPE html> declaration is much simpler. The PUBLIC and SYSTEM DTD identifiers should be removed from these declarations:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Strict//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.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.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

HTML pages that include a DTD (DOCTYPE definition) in the document type declaration as shown above may be interpreted as one of the older (1997, 1999, 2000 or 2001) versions of HTML or, worse yet, using quirks mode. Once the PUBLIC FPI and DTD identifiers have been removed, the pages should only be interpreted as HTML 5 standards mode documents.

History of HTML DOCTYPE

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 the supposedly standard versions of HTML is being used. As a result, some browsers would ignore most changes to the DTD, such as overriding the default value of attributes, and render the document differently than browsers that used the DTD as intended. For that reason, the references to the DTD have been dropped from the <!DOCTYPE html> tag, but the declaration is still included to indicate the HTML version.


Valid HTML 5