Validating Your HTML
Just as you use a spell-checker to catch
typos in your word-processing documents
before distributing them, you should routinely
use an HTML validator to catch errors
in your Web pages before posting them
live or running them through an accessibility-checking
tool.
Why?
An eloquent case
for validation .
HTML errors -- even tiny ones -- can
wreak serious havoc with the way "user
agents" (browsers, assistive technologies,
printers, indexing engines, validation
tools) interpret your Web pages. Poorly
coded pages that look perfect in a forgiving
browser like Internet Explorer are likely
to break and be inaccessible in another
browser. You may even crash your visitor's
computer. HTML errors can also keep your
style sheets from working properly and
hamper your efforts to validate your site's
508 compliance.
You cannot possibly cross-platform test
your site using every assistive technology
and every browser/hardware combination
on the market, but you can
ensure than your HTML is error-free. This
will go a long way to ensuring accessibility
for all users regardless of what device
they're using.
Do
I need to check my syntax even if I use
a WYSIWYG program such as Dreamweaver,
FrontPage, or GoLive to create my pages?
Yes.
In fact, you especially
need to check your syntax if you're using
one of these programs. The more a page
is edited and re-edited in a WYSIWYG ("what
you see is what you get") program, the
more syntax errors will creep in. This
is particularly true if the author is
an HTML novice or is paying more attention
to the page's visual presentation than
to its underlying structure. FrontPage's
HTML output tends to resemble a train
wreck under almost any circumstances.
Whether
you code by hand or use a page-authoring
program, you should run pages through
an HTML validator every time you update
them. There's an advantage for you as
a page author: validating and correcting
your HTML on a regular basis is the quickest
way to turn yourself into an HTML expert,
and it's more fun than studying manuals.
Being able to write your own HTML has
many
advantages; if you want to make your
pages 508-compliant, it's indispensable.
Contractors
built my site. They took care of HTML
validation before they posted my pages,
didn't they?
In
a perfect world, yes. In reality, don't
count on it. Too many professional developers
tend to assume that a page's underlying
source code is problem-free as long as
the page looks fine in Internet Explorer
for Windows, or whatever browser the developer's
office happens to be using.
But
let's say that your contractor delivered
you a set of perfect, error-free templates.
These pages can still accumulate syntax
problems once they are re-opened and edited.
How
do I validate my HTML?
Even people who write HTML by hand all
day long make mistakes. Fortunately, there
are a number of good syntax-checkers out
there.
The
World
Wide Web Consortium's HTML Validation
Service is a free, web-based tool
that can be used by anyone. You can either
enter the the URL of the page you want
checked or upload files from your hard
drive.
HomeSite
(for Windows) and BBEdit
(for Mac) both have good built-in syntax
checkers, which don't require an Internet
connection and can be quicker and more
convenient than using the W3C's online
service. Macromedia
Dreamweaver is well integrated with
these two products. If you are using Dreamweaver
4, you will find trial versions of BBEdit
and HomeSite on your installation CD.
You can switch back and forth between
Dreamweaver and BBEdit (or Homesite) and
automatically see changes and updates.
See the Dreamweaver
support center tech file for instructions
on using Dreamweaver in conjunction with
HomeSite or BBEdit.
No
tool is infallible. W3C's HTML Validator
will catch some things that BBEdit's checker
misses, such as multiple ALT attributes
for a single image. Conversely, BBEdit's
checker will alert you to missing closing
tags that the online Validator will miss.
For optimal results, you may want to use
both.
The Importance of DOCTYPE
All HTML files must
begin with a DOCTYPE tag to tell user
agents (including validation tools) what
version of HTML the page is written in.
The DOCTYPE tag should be the first line
of your file, preceding the opening <HTML>
tag.
We will not subject you to a long discussion
of DOCTYPE here (though please contact
us if you're interested in knowing more).
Suffice to say that the the current version
of HTML is 4.01. It supports three Document
Type Definitions (DTDs):
-
The HTML 4.01 Strict DTD
includes all elements and attributes
that have not been deprecated or do
not appear in frameset documents.
A deprecated element or attribute
is one that has been outdated by newer
constructs. Deprecated elements (e.g.,
presentational markup such as FONT
tags) are being phased out and may
become obsolete in future versions
of HTML. For documents that use the
Strict DTD, use this document type
declaration:
<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
-
The HTML 4.01 Transitional
DTD includes everything in
the strict DTD plus deprecated elements
and attributes (most of which concern
visual presentation). For documents
that use this DTD, use this document
type declaration:
-
<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
Or you can leave out the DTD and
just write:
<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
-
The HTML 4.01 Frameset DTD
includes everything in the transitional
DTD plus frames as well. For documents
that use this DTD, use this document
type declaration
<!DOCTYPE HTML
PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
"http://www.w3.org/TR/html4/frameset.dtd">
Your site is almost certainly using the
HTML 4.01 Transitional,
unless you use frames.
Resources: