CSS: ID selector
match ID attribute's value
#val-
match the value of a attribute
idsame as
[id="val"]#x2795 { border: solid 1px grey; }
tagName#val-
same as
tagName[id="val"]🟢 TIP: normally you don't need the tagName, because ID attribute should be unique on a page. There is only one element with a given ID value.
CSS, Selectors
simple selectors
- CSS: element selector (tag name)
- CSS: universal selector (* any tag)
- CSS: class selector
- CSS: ID selector
- CSS: attribute selector
- CSS: multiple attributes selector
selector list
relationship selectors (combinators)
- CSS: descendant selector (space)
- CSS: child selector (>)
- CSS: subsequent sibling selector (~)
- CSS: adjacent sibling selector (+)
special selector
- CSS: :root selector
- CSS: no child selector
- CSS: sibling selector
- CSS: pseudo-class selector (:)
- CSS: pseudo-element selector (::)
- CSS: negation selector (:not)
- CSS: is any of selector (:is, :where)
- CSS: :has descendant selector