EPUBCheck HTM-047: viewport syntax error
Updated:
EPUBCheck HTM-047 is an error message: “Viewport metadata "…" has a syntax error.” The viewport meta element of a fixed-layout document has a syntax error. The content attribute must be a list of name=value properties separated by commas, semicolons or spaces, and EPUBCheck quotes the value it could not parse.
The official message
Viewport metadata "%1$s" has a syntax error
- 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
- Wrong separators or a missing equals sign in the content attribute.
- Misspelled keys or stray characters, for example a trailing comma or quotes inside the value.
How to fix it
- 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.
- Write it as
content="width=1200, height=1600": width and height, each with a value, separated by a comma. - Keep other viewport properties out of fixed-layout pages unless you need them; reading apps ignore them.
- Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.
When it's not this
If the syntax is fine but width or height is missing, that is HTM_056; a bad value is HTM_057.
Terms used here
Other HTM messages
HTM-046Fixed layout document has no "viewport" meta element.HTM-048SVG Fixed-Layout Documents must have a "viewBox" attribute (on the outermost "svg" element).HTM-045Encountered empty href.HTM-044Namespace uri "…" was included but not used.HTM-051Found Microdata semantic enrichments but no RDFa. EDUPUB recommends using RDFa Lite.HTM_054Custom attribute namespace ("…") must not include the string "…" in its domain.
Sources
Message text and severity from EPUBCheck 5.4.0 (W3C, BSD-3-Clause). Explanation by EpubCC.