I accidentally introduced a CSS stylesheet error on my ePub3 compile settings. Can I fix it in Scrivener directly?

Hello!

I’m creating a compile template which I would like to use for a series of short story anthologies. I have everything formatted the way I like, but when I run the finished ePub3 file through a validator, it returns a CSS syntax error. The error looks like this:

Code: CSS-008
File (line, col) /OPS/css/stylesheet.css (line 40, col 8)
Message: An error occurred while parsing the CSS: Token “-” not allowed here, expecting :.

I used Calibre’s autocorrect syntax feature, which resolved the error. The ePub3 passes the validator (and everything looks the same as it did in Kindle Previewer).

Is there a way to fix the stylesheet settings within Scrivener itself? I’m not sure how I introduced the error.

It is almost impossible to advise more precisely, with only the error message and not the CSS excerpt itself that caused the error, for future reference (especially given that hyphens are typically valid in class names and such).

Best I can say is to in general look through your style naming, both in the project and in the compile format (if you’ve customised it). That’s the main place where what you type in can end up in the CSS. We clean what you type in to be valid, but maybe if you use a bizarre symbol or emoji or something it’s not being caught, or what looks like a “hyphen” in your error message actually isn’t (some unicode dash width, for instance).

looks like: element { property- value;}
instead of : element {property: value;}

or: element-hover { property: value;}
instead of : element:hover { property: value;}

1 Like