EPUBCheck HTM-046: fixed layout without viewport
Updated:
EPUBCheck HTM-046 is an error message: “Fixed layout document has no "viewport" meta element.” A fixed-layout XHTML document has no viewport meta element, so reading apps do not know its page size. In fixed layout, the width and height in the viewport define each page's coordinate space; without them the page cannot be laid out as designed.
The official message
Fixed layout document has no "viewport" meta element.
- 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
Typical causes
- Fixed-layout pages written without the viewport declaration.
- A book declared as pre-paginated in the package document whose chapters were written as reflowable text.
How to fix it
- Add a viewport in the head of each fixed-layout page with its width and height in pixels, for example
<meta name="viewport" content="width=1200, height=1600"/>. - Use the size the page was designed for (often the pixel size of its background image).
- If the book is not meant to be fixed layout, remove rendition:layout "pre-paginated" from the package document instead.
- Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.
When it's not this
If the page is SVG rather than XHTML, the missing size is a viewBox and the message is HTM-048.
Terms used here
Other HTM messages
HTM-045Encountered empty href.HTM-047Viewport metadata "…" has a syntax errorHTM-044Namespace uri "…" was included but not used.HTM-048SVG Fixed-Layout Documents must have a "viewBox" attribute (on the outermost "svg" element).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.