What is meant by the following selector?
.a .b + .c .d { ... }
Intended meaning (and way in which it appears to function): Select d inside c that is adjacent to b inside a
/* Brackets to hide ambiguity */
(.a .b + .c) .d
Is this correct use of the adjacenct sibling selector? What is the operator + precedence in CSS grammar?
Yes, that’s right. The way you placed your brackets also makes sense to me. Nest them some more to be clearer:
In this example, only the second
p.delement is matched:Not selected
This
p.delement isn’t contained in an element with the classc.Selected
This
p.delement is contained in a.celement. The.celement immediately follows a.belement, and both of these share the.aancestor element.Not selected
This
p.delement is contained in a.celement. However, this doesn’t immediately follow a.belement; instead it comes after another.celement, so itsp.ddoesn’t satisfy the selector.If the general sibling combinator
~were used instead of the adjacent sibling combinator+, as inThen this
p.dwould be matched.All compound selectors and combinators in a sequence are processed from right to left, using each selector group as a step. This answer elaborates. (This may be counter-intuitive when you think in brackets; to make sense of it simply treat the brackets as if the outermost ones came first. Either ordering is fine, though, as long as you remember that combinators aren’t associative. See the linked answer for details.)