css3 - Are parentheses allowed in CSS selectors? -
in below example, want create css rule applies header text "blockhead".
<div class="gumby"> <span class="pokey"></span> <h3>blockhead</h3> <h3>clay rules</h3> </div>
can utilize parentheses, such (gumby > pokey) + h3)
? if not, alternative?
no, parentheses not valid operators in css selectors. reserved functional notations, such :lang()
, :not()
, , :nth-child()
.
you don't need them anyway; .gumby > .pokey + h3
work fine.
this because sequence of selectors , combinators read linearly. combinators don't have sort of precedence. selector can interpreted as
select h3
element follows element class pokey
kid of element class gumby
.
and because of how node trees work, utilize of sibling , kid combinators here implies both .pokey
, h3
children of .gumby
, in case are, because of statement both of them siblings.
css css3 css-selectors
No comments:
Post a Comment