Are parentheses allowed in CSS selectors?
Solution 1:
No, parentheses are not valid operators in CSS selectors. They are reserved for functional notations, such as :lang()
, :not()
, and :nth-child()
.
You don't need them anyway; .gumby > .pokey + h3
by itself will work just fine.
This is because a sequence of selectors and combinators is always read linearly. Combinators don't have any sort of precedence. The selector can be interpreted as
Select an
h3
element
that immediately follows an element with classpokey
that is a child of an element with classgumby
.
And because of how node trees work, the use of sibling and child combinators here implies that both .pokey
and the h3
are children of .gumby
, which in your case they are, because of its statement that both of them are siblings.