CSS: class selector (.x)
match class name
.val-
Any element with attribute
classvalue of valSame as
[class~="val"].xx { border: solid 1px grey; }
match multiple class names
.val1.val2.etc-
Any element with attribute
classvalue of val1 and val2 and etc<div class="aa bb"> something </div> .aa.bb { border: solid 1px red; }
match tag name and class name
tag.val-
Element tag with attribute
classvalue of val.Same as
tag[class~="val"]nav.x6981 { border: solid 1px grey; }
HTML class attribute
CSS, Selectors
Selector types
- CSS: types of selectors
- CSS: simple selectors
- CSS: compound selectors
- CSS: complex selector (combinator)
Simple selectors
- CSS: type selector (tag name)
- CSS: universal selector (* any tag)
- CSS: class selector (.x)
- CSS: ID selector (#)
- CSS: attribute selector ([x])
Combinators
- CSS: descendant selector (space)
- CSS: child selector (>)
- CSS: adjacent sibling selector (+)
- CSS: subsequent sibling selector (~)
Selector list
Special selector
- CSS: :root selector
- CSS: no child selector
- CSS: sibling rank selector (first, last, nth)
- CSS: nth-child selector
- CSS: pseudo-class selector (:)
- CSS: pseudo-element selector (::)
- CSS: negation selector (:not)
- CSS: βis any ofβ selector (:is, :where)
- CSS: :has descendant selector