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=""
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 parser error : Specification
mandate value for attribute nowrap
<TD class="headerBg" bgcolor="#004F99" nowrap align="left">
^ parser error : attributes construct error
<TD class="headerBg" bgcolor="#004F99" nowrap align="left">
^ 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
Search WWH ::

Custom Search