WEEK: 3
Active: Not Currently Active
Work Due:

Doctype Declaration

The Doctype declaration simply tells a browser what type of HTML specification your site was written with.

In older versions of HTML and XHTML, the doctype included additional information on the page, as well as a reference link to the specification.

<!-- The doctype for HTML 4.01 looks like this: -->
<!DOCTYPE HTML PUBLIC"-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">


<!-- Here’s the doctype for XHTML 1.0: -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

They’re not very human-readable, but, in their own way, they are simply saying “this document is written in HTML 4.01,” or “this document is written in XHTML 1.0.”

You might expect the doctype declaring “this document is written in HTML5” would have the number five in it somewhere. It doesn’t. The doctype for HTML5 looks like this:

<!DOCTYPE html>

The doctype declaration should be the first thing in your HTML file; on line 1.


Previous section:
Next section: