HTML and CSS Reference
In-Depth Information
Every start-tag must have a matching end-tag.
Empty elements should use the empty-element tag syntax.
Every attribute must have a value.
Every attribute value must be quoted.
Every raw ampersand must be escaped as & .
Every raw less-than sign must be escaped as < .
There must be a single root element.
Every nonpredefined entity reference must be declared in the DTD.
In addition, namespace well-formedness requires that you add an xmlns="http://www.w3.org/1999/xhtml"
attribute to the root html element.
Although it's easy to find and fix some of these problems manually, you're unlikely to catch all of them without
help. As discussed in the preceding chapter, you can use xmllint or other validators to check for well-
formedness. For example:
$ xmllint --noout --loaddtd http://www.aw.com
http://www.aw-bc.com/:118: parser error : Specification
mandate value for attribute nowrap
<TD class="headerBg" bgcolor="#004F99" nowrap align="left">
^
http://www.aw-bc.com/:118: parser error : attributes construct error
<TD class="headerBg" bgcolor="#004F99" nowrap align="left">
^
http://www.aw-bc.com/:118: parser error : Couldn't find end
of Start-tag TD line 118
<TD class="headerBg" bgcolor="#004F99" nowrap align="left">
^
...
TagSoup or Tidy can handle many of the necessary fixes automatically. However, they don't always guess right,
so it pays to at least spot-check some of the problems manually before fixing them. Usually it's simplest to fix
as many broad classes of errors as possible. Then run xmllint again to see what you've missed.
The following sections discuss the mechanics and trade-offs of each of these changes as they usually apply in
HTML.
Search WWH ::




Custom Search