HTML and CSS Reference
In-Depth Information
Prior Versions oF HTML and docTyPes
If you're coding specifically for a non-HTML5 page, the use of a
doctype
is, unfor-
tunately, a lot more complex. There are a several
doctypes
that pertain to the for-
mer version, HTML 4.01. Moreover, a different
doctype
should be used if you're
coding your web page with the XHTML syntax. The choice of
doctype
directly
affects the way browsers render your pages, so a proper
doctype
is essential.
When you are working with HTML 4.01 (the last approved version of the web lan-
guage prior to HTML5), there are two basic choices:
strict
and
transitional
.
The
strict doctype
relies on a subset of HTML 4.01 which emphasizes struc-
ture over presentation. Numerous tags and attributes — including frames and link
targets — from previous versions of HTML that have been deprecated may not be
used. A
strict doctype
looks like this:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN”
The
strict doctype
is often used by designers who want to create a web stan-
dards-compliant site that relies on CSS for presentation and does not use outmoded
structures, such as frames.
The
transitional doctype
, on the other hand, allows a mix of the old and the
new. Code containing deprecated tags and attributes are allowed.
A transitional
doctype
looks like this:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN”
Several browsers — such as Internet Explorer 6 and 7 — enter into what is referred
to as quirks mode when they encounter a
transitional doctype
. Quirks mode
allows the browsers to render the page according to earlier standards.
Web pages coded with XHTML syntax have parallel
doctypes
to those using
HTML syntax. Here's an XHTML
strict doctype
:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Strict//EN”
The transitional doctype for XHTML is similar, but significantly different:
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
There are also HTML and XHTML
doctypes
for pages that rely on frames as well
as those for earlier versions of HTML.