Pattern:
E > F
Match any
F
element that is a child of
E
element
.
CSS example:
p > span { color: red; }
HTML example:
<p> Only <span>this </span> is red. </p>
Only this is red.
Pattern:
E + F
Matches if
E
and
F
share the same parent and
E
immediatly precedes
F
.
CSS example:
b + i { color: red; }
HTML example:
<b>Lorem</b> <i>ipsum</i> <u>dolor</u>
Pattern:
E ~ F
Matches if selector
E
and
F
share the same parent and
E
precedes
F
.
CSS example:
b ~ i { color: red; }
HTML example:
<b>Lorem</b> <u>ipsum</u> <i>dolor</i>
Pattern:
[E~=F]
Matches if
E
value contains the word
F
.
CSS example:
[class~=foo] { color: red; }
HTML example:
<b class="foo">Lorem</b> <u class="bar">ipsum</u> <i class="foobar">dolor</i>
Pattern:
[E^=F]
Matches if
E
value begins with
F
.
CSS example:
[class^=foo] { color: red; }
HTML example:
<b class="foo">Lorem</b> <u class="bar">ipsum</u> <i class="foobar">dolor</i>
Pattern:
[E$=F]
Matches if
E
value begins with
F
.
CSS example:
[class$=foo] { color: red; }
HTML example:
<b class="foo">Lorem</b> <u class="bar">ipsum</u> <i class="barfoo">dolor</i>