Skip to content
EPUBCheck · XHTML content documents

EPUBCheck HTM-004: unexpected DOCTYPE found

Updated:

EPUBCheck HTM-004 is an error message: “Irregular DOCTYPE: found "…", expected "…".” A document has a DOCTYPE other than the one expected for its type and EPUB version. EPUBCheck shows the DOCTYPE it found and the one it expected, so the fix is usually to copy the expected one.

The official message

Irregular DOCTYPE: found "%1$s", expected "%2$s".

Default severity
Error. The EPUB breaks a rule of the specification and is invalid. Stores and Send to Kindle may reject it, and EPUBCheck exits with status 1.
EPUBCheck version
5.4.0

%1$s, %2$s… are filled in with the file, value or element EPUBCheck found.

Typical causes

  • An XHTML 1.1 DOCTYPE left over from an EPUB 2 book inside a package that now declares EPUB 3.
  • A chapter template copied from a web page with an HTML 4 or XHTML 1.0 Transitional DOCTYPE.
  • An NCX or SVG file with a DOCTYPE that has the wrong public or system identifier.

How to fix it

  1. Open the file EPUBCheck names (the message gives the path, line and column) in a text or EPUB editor such as Sigil, or unzip the EPUB and open it there.
  2. For EPUB 3 XHTML chapters, replace the DOCTYPE with <!DOCTYPE html>.
  3. For other files, use exactly the DOCTYPE EPUBCheck shows as expected, or remove it where the format allows no DOCTYPE.
  4. Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.

When it's not this

If EPUBCheck says the DOCTYPE is obsolete and can be removed, that is HTM-009; HTM-004 shows the expected DOCTYPE.

Terms used here

Other HTM messages

  • HTM-003 External entities are not allowed in EPUB v3 documents. External entity declaration found: ….
  • HTM-001 Any publication resource that is an XML-based media type must be a valid XML 1.0 document. XML version found: ….
  • HTM-007 Empty or whitespace-only value of attribute ssml:ph.
  • HTM-009 The DOCTYPE provided is obsolete or irregular and can be removed.
  • HTM-010 Namespace "…" is unusual for the prefix "epub".
  • HTM-011 Entity is undeclared.

Sources

Message text and severity from EPUBCheck 5.4.0 (W3C, BSD-3-Clause). Explanation by EpubCC.

FAQ

What does EPUBCheck HTM-004 mean?

EPUBCheck HTM-004 is an error message: “Irregular DOCTYPE: found "…", expected "…".” A document has a DOCTYPE other than the one expected for its type and EPUB version. EPUBCheck shows the DOCTYPE it found and the one it expected, so the fix is usually to copy the expected one.

Is HTM-004 an error?

HTM-004 is reported as error by default. The EPUB breaks a rule of the specification and is invalid. Stores and Send to Kindle may reject it, and EPUBCheck exits with status 1.