Part 2 - (X)HTML

Doctypes

What are they and why are they important?

HTML 4.01 Strict

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

HTML 4.01 Transitional

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

HTML 4.01 Frameset

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

XHTML 1.0 Strict

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

XHTML 1.0 Transitional

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

XHTML 1.0 Frameset

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

XHTML 1.1

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

Standards compliant (or strict) and quirks modes

Most browsers run in two modes: quirks mode for the old rules and strict mode for the standard. Mozilla, Safari, Opera, Mac/Explorer, Windows/Explorer 6 implemented these two modes. Windows/Explorer 5 and older browsers like Netscape 4, are permanently locked in quirks mode.

There are some very important reasons to use strict, or standards compliant mode. For example, Windows/Explorer 6 will use the correct box model when in strict mode, but the incorrect box model when in quirks mode. Also, many modern browsers will not allow fonts to be inherited when in quirks mode.

Is the XML prolog necessary?

Using the XML prolog in XHTML documents is a practice that is recommended but not required by the W3C. So, it's up to developers whether to use it or to leave it out. If the prolog is included, Windows/IE6 will revert to quirks mode regardless of the doctype used. The prolog looks like this:

<?xml version="1.0" encoding="utf-8"?>

External resources: