EPUBCheck HTM_057: invalid viewport value
Updated:
EPUBCheck HTM_057 is an error message: “Viewport "…" value must be a positive number or the keyword "device-…".” A viewport width or height is not a positive number or the matching device keyword. EPUB allows a plain positive number or device-width for width and device-height for height.
The official message
Viewport "%1$s" value must be a positive number or the keyword "device-%1$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
EPUBCheck prints this ID with an underscore instead of a hyphen; this page uses the ID exactly as EPUBCheck reports it.
%1$s, %2$s… are filled in with the file, value or element EPUBCheck found.
Typical causes
- Values with units, such as 1200px or 100%.
- Zero, negative numbers or typos such as widht.
- The wrong keyword for the dimension, such as height=device-width.
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.
- Use a plain positive number, for example
width=1200, height=1600. - Or use device-width for width and device-height for height if the page should fill the screen.
- Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.
When it's not this
If a dimension is missing altogether, the message is HTM_056.
Terms used here
Other HTM messages
HTM_056Viewport metadata has no "…" dimension (both "width" and "height" properties are required)HTM_058HTML documents must be encoded in UTF-8, but UTF-16 was detected.HTM_055The "…" element should not be used (discouraged construct)HTM_059Viewport "…" property must not be defined more than once, but found values […].HTM_054Custom attribute namespace ("…") must not include the string "…" in its domain.HTM_060bEPUB reading systems must ignore viewport meta elements in reflowable documents; viewport declaration "…" will be ignored.
Sources
Message text and severity from EPUBCheck 5.4.0 (W3C, BSD-3-Clause). Explanation by EpubCC.