View Single Post
Old 01-07-2016, 04:00 AM   #5
dgatwood
Curmudgeon
dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.dgatwood ought to be getting tired of karma fortunes by now.
 
dgatwood's Avatar
 
Posts: 629
Karma: 1623086
Join Date: Jan 2012
Device: iPad, iPhone, Nook Simple Touch
Quote:
Originally Posted by Jellby View Post
I think :first-of-type is only CSS3 (and it would target the first <p>, provided it has a given class, not the "first p with a given class", I believe), so don't expect ePub 2 renderers to support it.
CSS4 offers :nth-match(). I wouldn't expect any reader to support it yet, though iBooks might support it in 10.11/iOS 9 and later if they've whitelisted it and if support made it into WebKit in time for that release. (I haven't tried.)

I think the syntax would be something like:

Code:
p:nth-match(0n+1 of .bar) {
...
}
but don't quote me on that.

With that said, either the next sibling operator (PeterT's suggestion) or the generic sibling selector will probably work, depending on whether you want the first matching paragraph after any non-matching paragraph to be formatted like the first matching paragraph. If you don't, then do something like this instead:

Code:
.attribution {  background-color: red;}
.attribution ~ .attribution {    background-color: green;}
dgatwood is offline   Reply With Quote