An ID selector targets the element whose HTML id attribute matches a specified value. Write the value with a hash symbol: #id-value. section 19.1 section 19.2
#id-value {
property1: value1;
property2: value2;
...
}
Use this pattern in an internal or external stylesheet, replacing id-value with the element's case-sensitive id. section 19.2
Two individually styled sections
Give two div elements the ids section-quote and section-summary, then style them separately with #section-quote and #section-summary. One rule controls the quote's italic, right-aligned appearance; the other controls the summary's bold, centered appearance. section 19.2
Choose between IDs and classes with this quick rule:
- Use an ID when the style belongs to one and only one element. section 19.2
- Use a class when styles apply to multiple elements, or might expand to more elements later. section 19.2
- Prefer classes in general because single-element ID rules can make CSS harder to maintain and troubleshoot. section 19.2


