Explanation of the error messages
for the W3C Markup Validator

These error explanations were originally written by Scott Bigham, and are used here with his permission.

Table of Contents

Listing of errors and their explanation

ID "FOO" already defined

You have defined the id/name "FOO" more then once. You will also get a message telling you where it was first defined. Be aware that this message may be the result of an ambiguity in the specification. While user-agents must treat values of the id attribute as case-sensitive, they must still be case-insensitive unique in the document. See Section 12.2.1 Syntax of anchor names in the HTML 4.01 Recommendation for further information.

entity end not allowed in comment

Unterminated comment. The position indicator points to the very end of the file, where the problem was detected; to find the beginning of the comment, try searching for the last occurrence of "<!--" in the document.

name start character invalid: only s and comment allowed in comment declaration

Unterminated comments again. This time, you have a case like:

<!-- This is the first unterminated comment >
<!-- This is the second one >

The validator (correctly) interprets the "--" in the second comment as terminating the first comment, and then interprets the text of the second comment as text between comments, which is not allowed.

unknown declaration type "FOO"

Most likely an invalid comment of the form "<!invalid comment>"; the validator is (correctly) attempting to interpret it as an SGML markup declaration.

an attribute value must be a literal unless it contains only name characters

You have an attribute whose value needs to be in quotes. If an attribute value contains any character other than letters, digits, hyphens and periods, it must be enclosed in double quotes (single quotes would also be OK from an SGML standpoint, but some browsers don't recognize them).

character "X" not allowed in attribute specification list

The validator has found a character inside an HTML tag that isn't allowed there. This usually means you didn't put an attribute value in quotes when necessary. It also probably means that the character in question is not allowed in the value of the attribute at all, or you would have received the previous error instead. See below for more information.

You can also get in trouble by forgetting the closing quote on an attribute. For instance:

<img src="http://foo.com/fred.gif>
<img src="http://foo.com/joe.gif>

The validator will (correctly) interpret this as a src value of "http://example.com/fred.gif> <img src=", and then choke on the following ":". In this case, the position indicator in the error message may be several lines below the line with the missing quote.

length of attribute value must not exceed LITLEN less NORMSEP (1022)

This usually occurs in conjunction with the previous error. It almost always means that you've forgotten a closing quote on an attribute value. For instance, in:

<img src="fred.gif>
<!-- 50 lines of stuff -->
<img src="joe.gif">

The "src" value for the first <img> is the entire fifty lines of stuff up to the next double quote, which probably exceeds the SGML-defined length limit for HTML string literals. Note that the position indicator in the error message points to where the attribute value ended — in this case, the "joe.gif" line.

element "FOO" undefined

You've used an unknown tag (represented here by "FOO"). Make sure the DTD indicated by your DOCTYPE actually includes this element.

If the tag in question is a frame-related tag you must use the "Frameset" DTD, and if you use (deprecated) physical markup ("FONT" and friends) you must use the "Transitional" DTD.

document type does not allow element "FOO" here

Straightforward, but not terribly informative. There are several different mistakes that will generate this error message:

  • Using an unknown tag. In this case, the next error will be element "FOO" undefined".
  • Using a tag in the wrong place. For instance, <table><td>blah</table> will cause this error. The trick here is that a <table> element cannot directly contain <td> elements; it contains one or more <tr> elements which in turn contain <td> elements. The above example should be <table><tr><td>blah</table>.
document type does not allow element "FOO" here; assuming missing "BAR" start-tag

Similar to the previous error, but more specific: in this case, you have a "FOO" element that is not contained in a "BAR" element when "FOO" is not allowed outside of "BAR". Some of the most common causes of this error are:

  • Using the "<dd>" element as a fake paragraph indent. "<dd>" is not allowed outside of a "<dl>" element.
  • Improper construction of a nested list. An inner "<ul>" or "<ol>" in a nested list may not appear directly within an outer "<ol>" or "<ul>", but only within an "<li>" of the outer "<ol>" or "<ul>", as in the following example: <ol>
     <li>Obtain the following items:
      <ul>
       <li>Ham</li>
       <li>Bread; one of:
        <ul>
         <li>White</li>
         <li>Rye</li>
         <li>Whole wheat</li>
        </ul>
       </li> <!-- End of the "Bread" <li> -->
       <li>Cheese</li>
      </ul>
     </li> <!-- End of the "Obtain" <li> -->
     <li>Place ham and cheese between two slices of bread</li>
     <li>Consume the resulting ham-and-cheese sandwich</li>
    </ol>

    The "</li>" end tags are optional and are only included above to emphasize how the structure of the nested list is arranged; if you omit them, the parser will infer their presence in the locations shown above.

The validator has inserted a "BAR" start tag where it thinks there needs to be one; it will probably complain later on that the corresponding end tag is also missing.

there is no attribute "FOO" for this element

You have used an attribute with an element that is defined not to have that attribute. This is most commonly caused by using vendor-specific attributes without setting the document type appropriately.

"FOO" is not a member of the group specified in the declared value of this attribute

Similar to the previous error; this time, you're using an attribute that is defined for the element, but with a value that isn't defined for the attribute. For instance, the Netscape extension <img align="absmiddle"> will cause this error; "absmiddle" is not one of the allowed values for the "align" attribute of <img> (unless, of course, you provided a Netscape document type).

If you're using the Netscape document type, the "border" attribute of "<table>" can cause this error.

This error can also be caused, oddly enough, by missing close quotes on attribute values. For instance, given:

<img src="fred.png> <img src="joe.png>

The validator will (correctly) see a src attribute of "fred.png> <img src=", and then try to interpret joe.png as an attribute of <img>.

syntax of attribute value does not conform to declared value

Yet another attribute error; this time, the attribute in question was defined to take a numeric value, or an SGML identifier value, and you used a character that doesn't match what it was expecting.

One potentially annoying source of this error is the width attribute on the td element. Whether intentionally or by oversight, the HTML 3.2 DTD defines this attribute to have a value type of NUMBER, which means that <td width="50%"> is not allowed.

value of attribute "FOO" invalid: "#" cannot start a name

A special case of the previous error; the attribute in question is defined to take as value an SGML NMTOKEN, a name token, which must begin with a letter.

"FOO" is not a member of a group specified for any attribute

Another attribute error, this time referring to an "abbreviated" (minimized) attribute. SGML allows you to omit the name of an attribute if the attribute value is unambiguous. For instance, "<img ismap>" is actually an abbreviation of <img ismap="ismap">. The validator has found something that looks like an abbreviated attribute but doesn't match the value of any attribute for this element. For instance, a typo like "<img isnap>" would produce this error.

A missing close quote on a previous attribute value can also trigger this error if the next quote it finds is followed by something that looks like an abbreviated attribute; for instance,

<img src="fred.png><img src="joe.png>

would produce this error, referring to the "attribute value" joe.png.

required attribute "FOO" not specified

You left off a required attribute of the indicated element. The most common such omitted attribute is the alt attribute of the area or img element; browsers will typically use these to build a menu equivalent to your client-side image map if the user has disabled image loading, so you'll want to use a meaningful value here.

end tag for "FOO" omitted, but its declaration does not permit this

You forgot to close something. "FOO" is the element you forgot to close (and the next message, "start tag was here" points to the particular instance of "FOO" in question); the positional indicator points to where the validator expected you to close the element. There are a few common ways that this can happen:

  • You've put something inside the "FOO" element that isn't allowed there. For instance,

    <ul><li><h4>fake font change</h4></li></ul>

    will cause this error, since headers aren't allowed inside <ul> elements; the validator assumes that you meant to close the <ul> before opening the <h4>.

  • Interlocked elements. For instance, <b><i>nope</b></i> will cause this error. HTML requires that you close elements inside-out — that is, the last element you opened is the first element you should close. In this example, you'd have to close the <i> before the <b>.
  • Unclosed <a> tags. Yes, even <a name="foo"> has to have a corresponding </a>. Note that an empty <a name="foo"> element won't be recognized by some browsers; be sure to put at least a word or two inside the <a>.
  • Having unadorned text where the validator was expecting a sub-element of "FOO". For instance, <dl>fake indent</dl> will produce this error, since inside a <dl>, the validator only expects to see <dt> and <dd> elements (i.e. you can't just put text in there).
  • A tag of the form <table width=100%>. The previous error should have been that the "%" was "not allowed in attribute specification list".

    What's happening here is that, in trying to get past the "%", the validator has become confused and thinks the "%" is inside the <table>…</table>, thus triggering the error message for the previous reason. This error will likely be followed by mistaken complaints that your <tr> elements are "not allowed here", plus a complaint about your </table> end tag. The solution is to put the attribute value in quotes; ie. <table width="100%">.

In general, you should always explicitly close all elements and quote all attribute values!

end tag for element "FOO" which is not open

The validator found an end tag, represented here by "FOO", without a corresponding start tag. This frequently occurs in conjunction with the previous error. For instance, given <b><i>nope</b></i>, the validator will insert a </i> before the </b>, and then will find the </i> after the </b> and will have nothing to match it with.

A subtle variation of this is <p><h4>fake font change</h4></p>. <h4> elements are not allowed inside <p> elements, but since HTML allows you to omit the </p> end tag for paragraphs (unlike XHTML), the validator assumes that you meant <p></p><h4>fake font change</h4></p>, in which case the final </p> is indeed superfluous.

This error can also be caused by incorrectly supplying an end tag for "empty" elements like <hr>, <br> or <img>. This is why they are written <hr />, <br />, and <img /> in XHTML.

end tag for "FOO" which is not finished

You have a "FOO" element, but you have omitted some required sub-element of it. For instance, a table with no tr's would cause this error.

start tag for "FOO" omitted, but its declaration does not permit this

The validator expected you to start a "FOO" element at the indicated point. This probably means you've put unadorned text somewhere it isn't allowed; for instance, <ul>fake indent</ul> will cause this error.

unknown entity "FOO"

The validator has found an entity (something like &this;) that it doesn't recognize. There are a few possibilities:

  • A reference to a URL that uses "&" as a separator between parameters, such as "http://example.com/cgi-bin/prog?x=1&y=2".

    To solve this problem, simply replace all the &'s in attribute values with &amp; (user agents will convert them back before following the links).

    Another way to get around this problem is for the author of the CGI program to allow a different value to be used between arguments, like ";" or "|", which would allow the link to be coded as e.g. <a href="http://example.com/cgi-bin/prog?x=1;y=2">

  • An unterminated entity; for instance, "this&ampthat" for "this&that", which the validator (correctly) interprets as a request for the entity "&ampthat;". Technically, any non-alphanumeric character (such as a space) will suffice to terminate the entity, but some browsers get this wrong; the safest thing to do is to terminate all entities with a semicolon, turning our example into "this&amp;that".
  • The entity &quot; in conjunction with the HTML 3.2 DOCTYPE. This entity was accidentally omitted from the most recent version of the HTML 3.2 DTD. You should be able to ignore this error safely, though if you wish, you can replace &quot; with the equivalent character entity &#34;.
non SGML character number ###

You have used an illegal character in your text. HTML uses the standard UNICODE Consortium character repertoire, and it leaves undefined (among others) 65 character codes (0 to 31 inclusive and 127 to 159 inclusive) that are sometimes used for typographical quote marks and similar in proprietary character sets. The validator has found one of these undefined characters in your document. The character may appear on your browser as a curly quote, or a trademark symbol, or some other fancy glyph; on a different computer, however, it will likely appear as a completely different character, or nothing at all.

Your best bet is to replace the character with the nearest equivalent ASCII character, or to use an appropriate character entity. For more information on Character Encoding on the web, see Alan Flavell's excellent HTML Character Set Issues reference.

This error can also be triggered by formatting characters embedded in documents by some word processors. If you use a word processor to edit your HTML documents, be sure to use the "Save as ASCII" or similar command to save the document without formatting information.

cannot generate system identifier for entity "HTML"

Your DOCTYPE declaration contains a public identifier that the validator does not recognize. See the discussion of DOCTYPE for an explanation of what's happening, and what public identifiers the validator recognizes.

missing a required sub-element of "FOO"

The element "FOO" is defined to require one or more sub-elements. One example is tr which requires one or more td or th elements.

start tag was here

Not an error, but rather a pointer to the start tag of the element the previous error referred to.

text is not allowed here; try wrapping the text in a more descriptive container

The document contained bare text where an element was expected. For instance, you must wrap text in <p> if it appears directly inside the <body>.

This error may also indicate an unquoted attribute value containing a reserved character (such as "/") which terminates the attribute. The net effect is that the rest of the attribute value appears to be plain text, outside any element, to an SGML parser.

value of attribute "FOO" cannot be "BAR"; must be one of "FOO", "BAR", "BAZ"

An attribute was specified to contain one of a set of predefined values and you have used a value that is not in that set. The error message tells which attribute value was unknown and the possible legal values for this attribute.

character "FOO" not allowed in attribute specification list possibly caused by a missing quotation mark ending a previous attribute value

A character that is illegal in the attribute list for a particular attribute was encountered. It's is likely that this is a result of a missing quote character on a previous attribute value.

duplicate specification of attribute "FOO"

You have specified an attribute more than once. For instance, you have used the "height" attribute twice on the same "img" tag.

invalid attribute value

The value of this attribute is not a legal value for attributes. For instance, the attribute cannot be the empty string. This is distinct from errors related to illegal values for a specific attribute.

an attribute specification must start with a name or name token

An attribute name (and some attribute values) must start with one of a restricted set of characters. This error usually indicates that you have failed to add a closing quotation mark on a previous attribute value (so the attribute value looks like the start of a new attribute) or have used an attribute that is not defined (usually a typo in a common attribute name).

invalid comment declaration; check your comment syntax

There is a syntax error in an SGML Comment Declaration. This may be caused by too many or too few hyphens "-" or that you have included an invalid character in the comment. The next message will be "comment declaration started here".

element "FOO" not allowed here; assuming missing "BAR" start-tag

The referenced element "FOO" isn't allowed in the context it occurs in, but it would be if it was wrapped in a "BAR" element. The Validator has assumed that you have forgotten to add a "BAR" start tag and continued validation as if it was there. You should check if this is the case and insert the proper tag.