ID selector
The ID selector matches the single element whose id attribute equals the given value.
Syntax
#identifier { } Examples
#main-nav { position: sticky; top: 0; }
#hero { min-height: 60vh; }
Output
Styles the unique elements with id "main-nav" and "hero".
Notes
Specificity is 0,1,0,0, which is very high and hard to override; prefer classes for styling. IDs must be unique per document. Useful as JS and fragment-link targets rather than style hooks.
Browser & runtime support
| Environment | Since version |
|---|---|
| chrome | 1.0 |
| firefox | 1.0 |
| safari | 1.0 |
| edge | 12 |