Skip to content
EPUBCheck · Stylesheets

EPUBCheck CSS-004: CSS file not in UTF-8

Updated:

EPUBCheck CSS-004 is an error message: “CSS documents must be encoded in UTF-8, detected …;.” A CSS file uses an encoding other than UTF-8 or UTF-16, which EPUB does not allow. Accented letters and symbols in content: strings or font names can then display wrongly; EPUBCheck names the encoding it detected.

The official message

CSS documents must be encoded in UTF-8, detected %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

%1$s, %2$s… are filled in with the file, value or element EPUBCheck found.

Typical causes

  • A stylesheet saved as ISO-8859-1 or Windows-1252.
  • A @charset rule at the top of the file naming another encoding.

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. Convert the file to UTF-8 in your editor or with a tool such as iconv.
  3. Change the @charset rule to @charset "UTF-8"; or remove it.
  4. Rebuild the EPUB and run EPUBCheck again to confirm the message is gone.

When it's not this

If the file is UTF-16, that is only the warning CSS-003.

Terms used here

Other CSS messages

  • CSS-003 CSS document is encoded in UTF-16. It should be encoded in UTF-8 instead.
  • CSS-005 Conflicting alternate style tags found: ….
  • CSS-002 Empty or NULL reference found.
  • CSS-006 CSS selector specifies fixed position.
  • CSS-001 The "…" property must not be included in an EPUB Style Sheet.
  • CSS-007 Font-face reference "…" refers to non-standard font type "…".

Sources

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

FAQ

What does EPUBCheck CSS-004 mean?

EPUBCheck CSS-004 is an error message: “CSS documents must be encoded in UTF-8, detected …;.” A CSS file uses an encoding other than UTF-8 or UTF-16, which EPUB does not allow. Accented letters and symbols in content: strings or font names can then display wrongly; EPUBCheck names the encoding it detected.

Is CSS-004 an error?

CSS-004 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.