An ID selector targets the element whose HTML id has a specified value. Write a hash (#) followed immediately by the ID, then add CSS declarations in braces. section 1.6.1
Use ID selectors carefully:
- Keep each ID unique on the page; repeating an ID makes the HTML invalid. section 1.6.1
- Prefer reusable class selectors when uniqueness is not essential, because ID-based rules are harder to reuse. section 1.6.1
- Remember that ID selectors have specificity value 100, so their styles can be difficult to override. section 1.5
Styling a uniquely identified blockquote
For a blockquote with id="quote-by-author", write: #quote-by-author { background: lightgrey; padding: 10px; line-height: 1.75; } The rule applies these declarations specifically to that blockquote. section 1.6.1
Listing 1.7 ID selector
#quote-by-author {
background: lightgrey;
padding: 10px;
line-height: 1.75;
}
View the complete ID-selector listing with background, padding, and line-height declarations. section 1.6.1


