Common XHTML Validation Errors
Unescaped Ampersand ("&")
- Example:
a href="foo.php?chapter=1§ion=2- Possible Validator Report:
Unknown entity...
- Solution:
- Always use
&in place of&. - Correct Syntax:
a href="foo.php?chapter=1&section=2
Incorrect Nesting of Elements
- Example:
<strong><em>...</strong></em>- Possible Validator Report:
Missing </em> tag
- Solution:
- Elements in XHTML must be closed in the reverse order that they were opened in.
- Correct Syntax:
<strong><em>...</em></strong>
Lowercase DOCTYPE
- Example:
<!doctype html public "-//w3c//dtd xhtml 1.0 strict//en"
"http://www.w3.org/tr/xhtml1/dtd/xhtml1-strict.dtd" >- Possible Validator Report:
Missing DOCTYPE
- Solution:
- The DOCTYPE is case-sensitive so use the correct case.
- Correct Syntax:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd" >
Missing closing " /"
- Example:
<img src="image.gif" width="100" height="100" alt="Logo">- Possible Validator Report:
Missing closing tag
- Solution:
- So-called "empty elements", such as
img, require a trailing space followed by a "/".
See XHTML Elements for a full list. - Correct Syntax:
<img src="image.gif" width="100" height="100" alt="Logo" />
Uppercase tags
- Example:
<STRONG><EM>...</EM></STRONG>- Possible Validator Report:
There is no such element...
- Solution:
- Use lower case for all element and attribute names.
- Correct Syntax:
<strong><em>...</em></strong>
Unquoted attribute values
- Example:
<td rowspan=3>- Possible Validator Report:
Missing quotation marks
- Solution:
- All attribute values must be quoted, even those which appear to be numeric.
- Correct Syntax:
<td rowspan="3">
Please send any comments to info@blackwidows.co.uk.