Repository navigation
Description
A stray semicolon in a declaration block is reported as a parse error when it
appears in a stylesheet, but not when it appears in a style attribute.
ERROR(CSS-008): EPUB/s.css(1,9): An error occurred while parsing the CSS:
Token ";" not allowed here, expecting a property name.
This was already accepted and fixed, for one path
#238 (2013) reports the same
message with the same reasoning — that CSS's declaration production matches
empty, so a declaration list may begin with ;. It was marked Accepted and
closed as Fixed by r450.
That fix is still working. Against 5.3.0, in a style attribute:
| attribute value | result |
|---|---|
;color:#000000 |
no error ← the #238 fix |
color:#000000 |
no error |
color: |
CSS-008 |
nonsense{{{ |
CSS-008 |
So the attribute path is still parsed and still reports genuinely malformed
values — it simply tolerates the empty declaration, correctly. The stylesheet
path does not:
a:link {;color: #000000} /* CSS-008 at 1,9 */
a:link {color: #000;;} /* CSS-008 at 1,21 */Why the tolerant behaviour is the right one
CSS Syntax Level 3 discards the token explicitly. In both 5.4.4 Consume a
style block's contents and 5.4.5 Consume a list of declarations, the step for
<semicolon-token> is:
Do nothing.
CSS 2.1's core grammar (Appendix G) makes each declaration slot optional:
ruleset
: selector [ ',' S* selector ]*
'{' S* declaration? [ ';' S* declaration? ]* '}' S*
;
Impact
CSS-008 is an ERROR, so it changes the verdict: a publication that is otherwise
completely clean fails the check because of a character that has no effect on
rendering. It occurs in the wild — the case that prompted this is a
commercially distributed EPUB whose stylesheet contains
a:link {;color: #000000;text-decoration: none;} and which is otherwise clean.
Reproduction
A minimal EPUB 3 whose only stylesheet is a:link {;color: #000000} reports
0 fatals / 1 error. Removing the single ; and changing nothing else reports
No errors or warnings detected.
Where it comes from
CSSHandler.error() turns any exception from the CSS parser into CSS-008
unconditionally, so this surfaces the tokenizer's strictness rather than a rule
the checker decided on. Consistent with that, no CSS-008 scenario in
content-document-css.feature covers this shape — content-css-syntax-error
is about unterminated blocks, which really are malformed.
Activity
rdeltour commentedon Sep 14, 2026
Thanks for the report, good catch! This is fixed in #1719.
Note that the bespoke CSS parser used by EPUBCheck is quite old now and not fully compliant with CSS Syntax Module Level 3… Some syntax issues like these come up from time to time and we try our best to fix them, but at some point I hope to use a fully conforming parser instead.
fix(CSS): allow extra semicolons in list of declarations