Deciphering W3 HTML Validation Errors
Posted on August 4, 2008 by Jason
Tagged as
HTML

The W3, in its best effort to maintain standards for web documents, has created a nifty validation service for our webpages. Unfortunately, a large proportion of the error messages provided are cryptic and difficult to understand. In this article, we’ll be delving into some of the common error messages, and how to fix them. If I’ve forgot any error messages, feel free to comment.
No DOCTYPE found! Attempting validation with HTML 4.01 Transitional.
- Problem: You have omitted the DOCTYPE element at the beginning of your document.
- Solution: Include a doctype.
- Notes: You can force a doctype in the validation settings, and find the one that gives you the least errors.
Missing xmlns attribute for element html. The value should be: http://www.w3.org/1999/xhtml
- Problem: You forgot the xmlns attribute for the <html> tag
- Solution: See the error description, the validator provides a sample <html> tag
Element … undefined
- Problem: The element (tag) you have used is not recognized by the doctype. May be caused by bad capitalization in XHTML, browser-specific elements (such as <marquee>), or is unavailable in the current doctype.
- Solution:
- XHTML requires elements to be in all lowercase
- Replace browser-specific (proprietary) with standardized elements
- Change the doctype (XHTML Strict to XHTML Frameset)
NET-enabling start-tag requires SHORTTAG YES
- Problem: Usually caused when you have a self close element (such as <br />) but used the wrong doctype (HTML4) for validation.
- Solution: Change your doctype to an XHTML one (recommended) or close the element like this (<br></br>)
Character … is not allowed in the value of attribute …
- Problem: You have included an invalid character in an attribute (e.g. ‘>’ in ‘id’). Usually caused by missing quotation marks (<div id=”blah>)
- Solution: Remove the character if error was caused by intentional naming, or double check for missing quotes.
Value of attribute … must be a single token
- Problem: You have a space in an attribute when it is not allowed (e.g. id=”blah two”). May also be caused by missing quotation marks, sometimes earlier in the document.
- Solution: Condense the attribute value into a single word (token).
Cannot generate system identifier for…
- Problem: Shown in our picture above, this error commonly shows up when you’ve added an ampersand (&) within the document. In this particular example, it’s part of a URL in a JavaScript tag.
- Solution: Replace the ampersand (&) with &
- Notes: This error will also cause the following warnings/errors:
- general entity [...] not defined and no default entity.
- reference not terminated by REFC delimiter.
- reference to external entity in attribute value.
- reference to entity [...] for which no system identifier could be generated
- XML Parsing Error: EntityRef: expecting ‘;’.
Required attribute “ALT”/”TYPE” not specified
- Problem: You neglected to add the attribute alt to an image or you neglected to add the attribute type to a style or script element.
- Solution: Add the alt attribute to an image: <img src=”IMAGE-URL” alt=”ALTERNATE TEXT” /> or add the type attribute to a script/style element: <style type=”text/css” src=”STYLE SHEET URL” rel=”stylesheet” /> and <script type=”text/javascript”></script>
There is no attribute…
- Problem: You’ve used an attribute that doesn’t exist in the standards (e.g. marginheight for <body>). You may also have bad capitalization.
- Solution: Remove the attribute, find an alternative using CSS. Make sure attribute is not capitalized in XHTML documents.
End tag for element … which is not open
- Problem: You have an extra end tag (e.g. <a href=”link”></a></a>)
- Solution: Remove the extra end tag.
End tag for … omitted, but OMITTAG NO was specified
- Problem: You forgot to add an end tag to an element or you forgot to self-close the element (<img />)
- Solution: Add the end tag, or self close it.
An attribute specification must start with a name or name token
- Problem: The validator does not recognize the attribute you used.
- Solution: Remove the attribute, or change the doctype to one that supports the attribute (target).
Character … is the first character of a delimiter but occurred as data
- Problem: The validator expected a tag or escaped character.
- Solution: If it’s an <. escape it with < and if it’s an &, escape it with &
- The validator also suggests that you may have forgotten to close a tag
XML Parsing Error: Opening and ending tag mismatch: … and …
- Problem: Tag A is opened after Tag B, but Tag B is closed before Tag A. Will usually cause other errors.
- Solution: Check that all tags are closed.
- Notes: May cause the following errors:
- XML Parsing Error: Premature end of data in tag …
- XML Parsing Error: Opening and ending tag mismatch: … and …