WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Is doctype really important

for

From: Terence de Giere
Date: Mar 15, 2004 1:56PM


Quite often now we see Doctype Declarations in web pages, much more so
than formerly. This first line in the page (it should be the first line
with nothing above it) is an instruction for an SGML or XML processing
system to tell it exactly what rules the structure of the code in the
page that follows is going to be. Most browsers until recently have
ignored the Doctype, but the newer browsers are now paying attention to
them. Especially if you use the 'strict' forms of HTML 4.0 or 4.01 or
xhtml 1.0 or you are using xhtml 1.1.

Most HTML on the Internet is invalid and out of specification. When
there is no Doctype, the HTML is undefined, and invalid, meaning that it
does not conform to specifically defined rules. When there is a Doctype,
the page might be valid HTML if it corresponds to the definition of HTML
specified by the Doctype. But it also might be invalid meaning that the
HTML in the page does not correspond to the Doctype. This latter
situation is very common on the web, the Doctype is there in the page,
but the HTML is the same old garbage HTML that appears in pages without
the Doctype. The purpose of the Doctype is to restrict the HTML in your
page to specific set of rules so the HTML has a known defined structure.
Then any HTML capable device that can process that Doctype can load the
page without error. It is especially important for CSS format because
the parse tree, the document structure has to have a precise definition
for the format to cascade down through all the page elements without
error, and for scripting to manipulate those same elements.

All the major browsers now have lots of error correction code to process
pages. So if the HTML is bad, it might get fixed, but you won't know by
looking at the page in the browser that there was a problem. But why
take a chance? Using a Doctype and validating your pages against that
Doctype is great quality control. A page without errors is less likely
to cause problems with all browsers because all browsers at least to
some extent rely on the various standards set by standards bodies and
industry consortiums. It is the safest path. HTML validation is similar
to compiling in other computer languages in that it checks for outright
syntax errors and other structural problems. Note: most HTML editors do
not validate HTML so having a Doctype is no assurance the HTML below it
is right. Dreamweaver by default adds a Doctype, but it will also allow
you to add things to the page that violate the Doctype. Dreamweaver also
has an HTML checker that incorrectly validates pages. You need to use an
external validator with most editors that follows the specifications for
SGML and/or XML.

Valid HTML pages are also forward compatible, as time goes on, more
browsers and other technologies incorporate the current standards, and
as smaller web access devices with less HTML error correction are
appearing all the time now, it is advisable to have the cleanest, most
standardized code possible.

Terence de Giere
<EMAIL REMOVED>




----
To subscribe, unsubscribe, suspend, or view list archives,
visit http://www.webaim.org/discussion/