This course will be retired on July 12, 2021. We recommend "CSS Basics" for up-to-date content.
Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Start a free Courses trial
to watch this video
Unlike a type selector, which targets every element with the corresponding element type, an ID selector lets us assign a unique ID to an element.
Quick Reference
Using ID selectors
ID selectors are declared using the pound (#) symbol, followed by the ID name.
#primary-content {
background: grey;
}
This selector will match the HTML element that has an ID attribute with the value primary-content
.
IDs are unique to the page, so an element can only have one ID and a page can only have one element with the same ID name.
You need to sign up for Treehouse in order to download course files.
Sign up