HTML and CSS Reference
In-Depth Information
You will run across people who will argue very strongly for both XHTML and HTML. The
authors of this topic tend to prefer XHTML, but we also recognize that HTML is every bit as
valuable to your users. In the end, writing clean, semantic markup is the most important
thing, whether you choose to do it in HTML or XHTML.
DOCTYPE: The Most Underappreciated Tag of All
All modern, valid (X)HTML documents must open with a DOCTYPE declaration. DOCTYPE is an
(X)HTML string created primarily as a validation mechanism. It indicates to the browser, valida-
tor, or other reading device what sort of document you are writing, as well as which specification,
or set of rules, you are writing it against. Most modern browsers actually display the page differ-
ently based on what DOCTYPE is declared (we'll cover the specifics of how different DOCTYPE s affect
browser display in Chapter 4). When you declare a DOCTYPE , you are effectively saying to the browser,
“I, the developer of this site, have chosen to write my code against the following specification, and
I'd really appreciate it if you'd use the same specification to render it.”
So what are these specifications? There are many possible DOCTYPE s, but for the purposes
of this topic, only four are significant:
HTML 4.01 Strict
HTML 4.01 Transitional
XHTML 1.0 Strict
XHTML 1.0 Transitional
Let's take a look at each in turn.
HTML 4.01 Strict
HTML 4.01 Strict allows for a trimmed-down version of HTML 4.01. HTML 4.01 Strict empha-
sizes structure over presentation. It does not contain deprecated and presentational elements
(such as font , center , or u ), nor does it allow for frames or link targets. Use a strict DOCTYPE
when you intend to write only 100 percent clean markup, free of presentational clutter. To
declare HTML 4.01 Strict, the first line of your markup document should be
HTML 4.01 Transitional
HTML 4.01 Transitional includes all elements and attributes of HTML 4.01 Strict but also sup-
ports older presentational attributes, deprecated elements, and link targets. Use a transitional
DOCTYPE when dealing with legacy files that may still contain some presentational markup (you
can always change the DOCTYPE to Strict once you completely clean up your legacy code). To
declare HTML 4.01 Transitional, make the following the first line of your document:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
Search WWH ::

Custom Search