CSS: ID selector (#)
match ID attribute's value
tag#val-
match the value of a attribute
idsame as
tag[id="val"]tag here is compound selector, or none, which means the universal selector (* any tag).
π’ TIP: normally you don't need the tag, because ID attribute should be unique on a page. There is only one element with a given ID value.
#x2795 { border: solid 1px grey; }
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: first child, sibling rank selector
- 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