ValidationProblems
Top Ten MarkUp Validation Problems
@@
Todo
- point to Tidy in the first paragraph
- each problem should have associated sample documents and links to the validator output
- of course, each problem should show the invalid markup
- maybe the validator output should be contained inline
- point to the "verbose" feature
- links to validator docs
- link to CSS Validator FAQ
- check what to link and what not
Missing encoding information
@@
- FAQ: Setting encoding in web authoring applications
- http://www.w3.org/TR/i18n-html-tech-char/#ri20040310.054442951
- http://www.w3.org/International/questions.html#chars
- http://www.w3.org/International/O-HTTP-charset.html
- http://www.w3.org/International/O-charset.html
- http://www.w3.org/International/tutorials/tutorial-char-enc.html
- http://ppewww.ph.gla.ac.uk/~flavell/charset/checklist.html
- http://www.cs.tut.fi/~jkorpela/chars.html
- http://www.webstandards.org/learn/askw3c/dec2002.html
Missing document type declaration
@@
- http://msdn.microsoft.com/library/en-us/dnie60/html/cssenhancements.asp?frame=true#cssenhancements_topic2
- http://www.mozilla.org/docs/web-developer/quirks/doctypes.html
- http://www.opera.com/docs/specs/doctype/index.dml
- http://www.hut.fi/u/hsivonen/doctype.html
- http://www.alistapart.com/articles/doctype/
- http://gutfeldt.ch/matthias/articles/doctypeswitch.html
- http://www.w3.org/QA/Tips/Doctype
- http://www.w3.org/QA/2002/04/valid-dtd-list.html
- http://www.w3.org/International/articles/serving-xhtml/
Missing "alt" and "type" attributes
@@
Ampersands ("&") in links
@@
- http://www.w3.org/mid/JIECLNBHBMDCKGNGPJOFEEACCBAA.aapo.romu@helsinki.fi
- http://www.w3.org/TR/html4/appendix/notes.html#h-B.2.2
- http://www.htmlhelp.com/tools/validator/problems.html#amp
Improper nesting of elements
Proprietary elements and attributes
@@
- embed
- body @leftmargin, @topmargin, @marginheight, @marginwidth
- frameset @border, @frameborder, @framespacing
- table @height
...
- http://lists.w3.org/Archives/Public/www-archive/2003Mar/att-0105/table.html
- http://www.alistapart.com/articles/flashsatay/
Markup in document.write()
The <script> and <style> elements in HTML 4 are very special elements. Here is an example:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> <script type="text/javascript"> alert("Björn"); </script> </head> <body> <p>...</p> </body> </html>
If you load the document in a browser that supports scripting, it would show you a message box containing "Björn" rather than "Björn". This is because the browser ignores markup inside the <script> element. Here is another example:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> <script type="text/javascript"> alert("Comments are <!--NOT--> ignored!"); </script> </head> <body> <p>...</p> </body> </html>
You will get a message box containing "Comments are ignored!" for the same reason, markup is ignored. But the browser somehow needs to
know where the <script> element is finished. It was unfortunately not possible to specify that everything up to </script> is considered part of the script, instead the first occurence of </ followed by a letter A-Za-z determines the end of the element. Here is an (illegal!) example:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> </head> <body> <script type="text/javascript"> document.write("<p>...</p>"); </script> </body> </html>
In this case, the first occurence of </ followed by a letter would be
! If you ignore the document.write() and ignore the
(remember, markup is ignored inside the <script> element) you get something like
<script type="text/javascript">...</p>"); </script>
And
does not match </script>, the validator complains
- end tag for element "P" which is not open
It isn't, is it? Remember that comments are ignored too, but let's have a look at them again
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> </head> <body> <script type="text/javascript"><!-- alert("--> BUH!"); //--></script> </body> </html>
The browser would present you a message box containing "--> BUH!". If it had ignored comments you would not see the "BUH!", would you? But let's do another (illegal!) example
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"> <html> <head> <title>...</title> </head> <body> <script type="text/javascript"><!-- document.write("<p>...</p>"); //--></script> </body> </html>
So the </script>
</nowiki>
And
does not match </script>. As before.
...
- http://www.w3.org/TR/html4/appendix/notes.html#h-B.3.2
- http://www.htmlhelp.com/tools/validator/problems.html#script
Confusing HTML and XHTML syntax
...
XHTML means lower-case
@@ (<META>, onMouseOver, etc.)
"non SGML" characters
@@