CSS: ID selector

By Xah Lee. Date: . Last updated: .

match ID attribute's value

#val

match the value of a attribute id

same 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
selector list
relationship selectors (combinators)
special selector
misc