# EPUBCheck HTM-004: unexpected DOCTYPE found, how to fix it

Source: https://epubcc.com/epubcheck/htm-004/ (updated 2026-11-04)

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.

- Official message (EPUBCheck 5.4.0): Irregular DOCTYPE: found "%1$s", expected "%2$s".
- Default severity: Error

## 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.

## Sources

- EPUB 3.3, §B. Allowed external identifiers: https://www.w3.org/TR/epub-33/#app-identifiers-allowed (read 2026-11-04)
- EPUB 3.3, §3.9 XML conformance: https://www.w3.org/TR/epub-33/#sec-xml-constraints (read 2026-11-04)

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