OverDocs

HTML doctypes Edit on GitHub In category: HTML

HTML 5 #html5

HTML 5 provides the simplest doctype, which is case-insensitive:

<!DOCTYPE html>

Note that HTML 5 does not have any reference to a DTD file, because HTML 5+ is not based on it anymore.

XHTML #xhtml

XHTML 1.1 has only one valid doctype declaration:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
   "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">

XHTML 1.0 provides more doctypes with some differences. The most recommended is of course strict. It does not allow deprecated tags and attributes.

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

There is also transitional (or loose) version of XHTML 1.0 DTD. It allows presentational markup or or deprecated elements (such as font). It does not allow framesets.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If you want to use frames, use the Frameset version:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN"
   "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">

HTML 4.01 #html4

HTML 4.01 also comes with few kinds of declarations possible. They meanings are the same as their XHTML 1.0 equivalents.

Strict version:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
   "http://www.w3.org/TR/html4/strict.dtd">

Transitional:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
   "http://www.w3.org/TR/html4/loose.dtd">

and frameset:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
   "http://www.w3.org/TR/html4/frameset.dtd">

Note

The difference is, that in HTML 4.01 you can omit so called system identifier and thus declaration becomes shorter:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">

Note also that declarations withous system identifier tends to switch the browser into quirks mode.

Learn more #learn-more

Comments #comments