Skip to content

EPUBCheck does not accept class selector in CSS :has pseudo-class #1618

Closed

Description

@theo-oup

Consider the following CSS syntax using the :has and :not pseudo-classes:

header :has(h1.header.chapter) {
  margin-top: 10px;
}

header :has(h1.header) {
  margin-top: 10px;
}

header :has(h1) {
  margin-top: 10px;
}

header :has(.header) {
  margin-top: 10px;
}

header :not(.header) {
  margin-top: 10px;
}

EPUBCheck v5.2.1 reports:

Validating using EPUB version 3.3 rules.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(1,13): An error occurred while parsing the CSS: Token "h1" not allowed here.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(1,13): An error occurred while parsing the CSS: Token "h1" not allowed here.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(5,13): An error occurred while parsing the CSS: Token "h1" not allowed here.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(5,13): An error occurred while parsing the CSS: Token "h1" not allowed here.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(9,13): An error occurred while parsing the CSS: Token "h1" not allowed here.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(9,13): An error occurred while parsing the CSS: Token "h1" not allowed here.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(13,13): An error occurred while parsing the CSS: Token ".header" not allowed here.
ERROR(CSS-008): css_has_class_test.epub/OEBPS/css_has_test.css(13,13): An error occurred while parsing the CSS: Token ".header" not allowed here.

The above CSS syntax is valid and EPUBCheck should accept it. It appears errors are reported for class selectors used in the :has pseudo-class. A class selector in the :not pseudo-class is accepted.

I have created a test EPUB file, which includes the CSS pattern above. Please see: https://www.dropbox.com/scl/fi/urum4me6egoda1g31bhfv/css_has_class_test.epub?rlkey=8ly58gasqpuq87bpfu42nfqtq&st=isyiymvu&dl=0

Activity

  1. rdeltour commented on Aug 14, 2025

    @rdeltour
    Member

    Thanks for the report and the test case!

  2. self-assigned this
    on Aug 14, 2025
  3. added a commit that references this issue on Sep 1, 2025
    6509da8
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

status: acceptedReady to be further processedtype: false-positiveThis issue is about valid content being incorrectly rejected

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    ⌂ 换网址