Some of the most common errors in XHTML are:
- Not closing empty elements (elements without closing tags)
- Incorrect:
<br>
- Correct:
<br />
- Not closing non-empty elements
- Incorrect:
<p>This is a paragraph.<p>This is another paragraph.
- Correct:
<p>This is a paragraph.</p><p>This is another paragraph.</p>
- Improperly nesting elements (elements must be closed in reverse order)
- Incorrect:
<em><strong>This is some text.</em></strong>
- Correct:
<em><strong>This is some text.</strong></em>
- Not specifying alternate text for images (using the
alt attribute, which helps make pages accessible for devices that don't load images or screen-readers for the blind)
- Incorrect:
<img src="/images/88x31.png" />
- Correct:
<img src="/images/88x31.png" alt="Bla Bla Bla" />
- Putting text directly in the body of the document
- Incorrect:
<body>Welcome to my page.</body>
- Correct:
<body><p>Welcome to my page.</p></body>
- Nesting block-level elements within inline elements
- Incorrect:
<em><h2>Introduction</h2></em>
- Correct:
<h2><em>Introduction</em></h2>
- Not putting quotation marks around attribute values
- Incorrect:
<td rowspan=3>
- Correct:
<td rowspan="3">
- Using the ampersand outside of entities (use
& to display the ampersand character)
- Incorrect:
<title>Cars & Trucks</title>
- Correct:
<title>Cars & Trucks</title>
- Using uppercase tag names and/or tag attributes
- Incorrect:
<BODY><P>The Best Page Ever</P></BODY>
- Correct:
<body><p>The Best Page Ever</p></body>
- Attribute minimization
- Incorrect:
<textarea readonly>READ-ONLY</textarea>
- Correct:
<textarea readonly="readonly">READ-ONLY</textarea>
This is not an exhaustive list, but gives a general sense of errors that XHTML coders often make.