No declaration for attribute

The DTD does not declare an attribute the element carries.

The message, as the validator reports it
No declaration for attribute lang of element note

Why it happens

  • An attribute the DTD does not know, a misspelling, or an attribute meant for another element.

How to fix it

Remove or rename the attribute, or add it to the element's <!ATTLIST …> in the DTD.

Example

Validated against note.dtd, below.

Reports the error
<note id="n1" lang="en">
  <to>Ana</to>
  <body>Hi</body>
</note>
Fixed
<note id="n1">
  <to>Ana</to>
  <body>Hi</body>
</note>
note.dtd
<!ELEMENT note (to, body)>
<!ELEMENT to (#PCDATA)>
<!ELEMENT body (#PCDATA)>
<!ATTLIST note id ID #REQUIRED>