epubcheck icon indicating copy to clipboard operation
epubcheck copied to clipboard

Epubcheck error caused by CSS pseudo class :has

Open siddoib opened this issue 10 months ago • 2 comments

In a CSS file, we have the following lines:

section.chunk.other div:has(img) 
{
  display: flex; 
  border-bottom: 1px solid #D7D2CB;
}

Any ePub file containing this CSS are being flagged by epubCheck 5.2.1 with the following error:

Validating using EPUB version 3.3 rules.
ERROR(CSS-008): 10.1093_45103.001.0001.epub/OEBPS/css/style.css(395,29): An error occurred while parsing the CSS: Token "img" not allowed here.
ERROR(CSS-008): 10.1093_45103.001.0001.epub/OEBPS/css/style.css(395,29): An error occurred while parsing the CSS: Token "img" not allowed here.
Check finished with errors
Messages: 0 fatals / 2 errors / 0 warnings / 0 infos

I can't see anything wrong with the ePub or the CSS, so this is possibility a false positive error message with epubCheck application. Maybe related to #1354?

siddoib avatar Mar 14 '25 10:03 siddoib

Thanks for the report! EPUBCheck's parser predates the :has pseudo-class, so yeah it's probably a false-positive. And yeas it is likely similar to #1354.

I'll fix it for the next maintenance release, and will make sure other functional pseudo-classes are covered too.

rdeltour avatar Mar 24 '25 16:03 rdeltour

@rdeltour, thank you so much for the confirmation.

siddoib avatar Mar 24 '25 16:03 siddoib