Thanks for this useful information.
This is a discussion on Common errors in xhtml within the Web Design forums, part of the Web Designing & Development category; hi I m here again for sharing my little ideas with you. hope you like it and give the good ...
hi
I m here again for sharing my little ideas with you. hope you like it and give the good responce. plz post ur views.
here is some common errors occur in XHTML.
- 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: [FONT=Courier New, monospace][SIZE=2]<br>[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<br />[/SIZE][/FONT]
Note that any of these are acceptable in XHTML: [FONT=Courier New, monospace][SIZE=2]<br></br>[/SIZE][/FONT], [FONT=Courier New, monospace][SIZE=2]<br/>[/SIZE][/FONT] and [FONT=Courier New, monospace][SIZE=2]<br />[/SIZE][/FONT]. Older HTML-only browsers interpreting it as HTML will generally accept [FONT=Courier New, monospace][SIZE=2]<br>[/SIZE][/FONT] and [FONT=Courier New, monospace][SIZE=2]<br />[/SIZE][/FONT].- Not closing non-empty elements
- Incorrect: [FONT=Courier New, monospace][SIZE=2]<p>This is a paragraph.<p>This is another paragraph.[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<p>This is a paragraph.</p><p>This is another paragraph.</p>[/SIZE][/FONT]
- Improperly nesting elements (Note that this would also be invalid in HTML)
- Incorrect: [FONT=Courier New, monospace][SIZE=2]<em><strong>This is some text.</em></strong>[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<em><strong>This is some text.</strong></em>[/SIZE][/FONT]
- Not putting quotation marks around attribute values
- Incorrect: [FONT=Courier New, monospace][SIZE=2]<td rowspan=3>[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<td rowspan="3">[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<td rowspan='3'>[/SIZE][/FONT]
- Using the ampersand character outside of entities
- Incorrect: [FONT=Courier New, monospace][SIZE=2]<title>Cars & Trucks</title>[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<title>Cars & Trucks</title>[/SIZE][/FONT]
- Using the ampersand outside of entities in URLs (Note that this would also be invalid in HTML)
- Incorrect: [FONT=Courier New, monospace][SIZE=2]<a href="index.php?page=news&style=5">News</a>[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<a href="index.php?page=news&style=5">News</a>[/SIZE][/FONT]
- Failing to recognize that XHTML elements and attributes are case sensitive
- Incorrect: [FONT=Courier New, monospace][SIZE=2]<BODY><P ID="ONE">The Best Page Ever</P></BODY>[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<body><p id="ONE">The Best Page Ever</p></body>[/SIZE][/FONT]
- Using attribute minimization
- Incorrect: [FONT=Courier New, monospace][SIZE=2]<textarea readonly>READ-ONLY</textarea>[/SIZE][/FONT]
- Correct: [FONT=Courier New, monospace][SIZE=2]<textarea readonly="readonly">READ-ONLY</textarea>[/SIZE][/FONT]
- 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 [FONT=Courier New, monospace][SIZE=2]head[/SIZE][/FONT] element.
[FONT=Courier New, monospace][SIZE=2]<link rel="stylesheet" href="/style/screen.css" type="text/css" />[/SIZE][/FONT]
[FONT=Courier New, monospace][SIZE=2]<script type="text/javascript" src="/script/site.js"></script>[/SIZE][/FONT]
Note: The format [FONT=Courier New, monospace][SIZE=2]<script …></script>[/SIZE][/FONT], rather than the more concise [FONT=Courier New, monospace][SIZE=2]<script … />[/SIZE][/FONT], is required for HTML compatibility when served as MIME type [FONT=Courier New, monospace][SIZE=2]text/html[/SIZE][/FONT].
- 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 [FONT=Courier New, monospace][SIZE=2]application/xhtml+xml[/SIZE][/FONT] and target only fully conformant browsers, or serve the page as [FONT=Courier New, monospace][SIZE=2]text/html[/SIZE][/FONT] and try to obtain usability in Internet Explorer 6 and other non-conformant browsers.
Thanks for this useful information.
Bookmarks