Skip to content
EPUBCheck · XHTML content documents

EPUBCheck HTM-048: SVG page without viewBox

Updated:

EPUBCheck HTM-048 is an error message: “SVG Fixed-Layout Documents must have a "viewBox" attribute (on the outermost "svg" element).” A fixed-layout document built as SVG has no viewBox on its outermost svg element, so its size is unknown. For SVG fixed-layout pages the viewBox is what defines the page's dimensions.

The official message

SVG Fixed-Layout Documents must have a "viewBox" attribute (on the outermost "svg" 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

  • SVG pages exported with width and height but without viewBox.
  • A viewBox placed on an inner svg or g element instead of the outermost one.

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. Add a viewBox to the outer svg element, for example viewBox="0 0 1200 1600" (x, y, width, height).
  3. Use the same width and height the artwork was drawn at, so nothing is cropped or stretched.
  4. Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.

When it's not this

If the fixed-layout page is XHTML, the size comes from a viewport meta element and the message is HTM-046.

Terms used here

Other HTM messages

  • HTM-047 Viewport metadata "…" has a syntax error
  • HTM-046 Fixed layout document has no "viewport" meta element.
  • HTM-045 Encountered empty href.
  • HTM-051 Found Microdata semantic enrichments but no RDFa. EDUPUB recommends using RDFa Lite.
  • HTM-044 Namespace uri "…" was included but not used.
  • HTM_054 Custom 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.

FAQ

What does EPUBCheck HTM-048 mean?

EPUBCheck HTM-048 is an error message: “SVG Fixed-Layout Documents must have a "viewBox" attribute (on the outermost "svg" element).” A fixed-layout document built as SVG has no viewBox on its outermost svg element, so its size is unknown. For SVG fixed-layout pages the viewBox is what defines the page's dimensions.

Is HTM-048 an error?

HTM-048 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.