Taken from Wikipedia.
Some of the most common errors in the usage of XHTML are:
Common errors
Some of the most common errors in the usage of XHTML are:
- Failing to realize that documents won’t be treated as XHTML unless they are served with an appropriate XML MIME type
- Not closing empty elements (elements without closing tags in HTML4)
- 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 (Note that this would also be invalid in HTML)
- Incorrect: <em><strong>This is some text.</em></strong>
- Correct: <em><strong>This is some text.</strong></em>
- Not putting quotation marks around attribute values
- Incorrect: <td rowspan=3>
- Correct: <td rowspan="3">
- Correct: <td rowspan='3'>
- Using the ampersand character outside of entities
- Incorrect: <title>Cars & Trucks</title>
- Correct: <title>Cars & Trucks</title>
- Using the ampersand outside of entities in URLs (Note that this would also be invalid in HTML)
- Incorrect: <a href="index.php?page=news&style=5">News</a>
- Correct: <a href="index.php?page=news&style=5">News</a>
- Failing to recognize that XHTML elements and attributes are case sensitive
- Incorrect: <BODY><P ID="ONE">The Best Page Ever</P></BODY>
- Correct: <body><p id="ONE">The Best Page Ever</p></body>
- Using attribute minimization
- Incorrect: <textarea readonly>READ-ONLY</textarea>
- Correct: <textarea readonly="readonly">READ-ONLY</textarea>
- Mis-using CDATA, script-comments and xml-comments when embedding scripts and stylesheets.
- This problem can be avoided altogether by putting all script and stylesheet information into separate files and referring to them as follows in the XHTML head element.
Note: The format <script …></script>, rather than the more concise <script … />, is required for HTML compatibility when served as MIME type text/html.HTML Code:<link rel="stylesheet" href="/style/screen.css" type="text/css" /> <script type="text/javascript" src="/script/site.js"></script>
- If an author chooses to include script or style data inline within an XHTML document, different approaches are recommended depending whether the author intends to serve the page as application/xhtml+xml and target only fully conformant browsers, or serve the page as text/html and try to obtain usability in Internet Explorer 6 and other non-conformant browsers.
- This problem can be avoided altogether by putting all script and stylesheet information into separate files and referring to them as follows in the XHTML head element.
