Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Preview
Start a free Courses trial
to watch this video
Learn about the difference in CSS selectors, what the C in CSS means, and why rules don't always cascade.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
In this video, we're gonna be talking
about selectors, and why the .car selector
0:00
is different than the other selectors,
we're using in our style sheet.
0:05
Let's check it out.
0:09
Moving down the CSS page, I wanna
introduce you to the .car selector.
0:11
This kind of selector, is not like an
element selector.
0:16
Like a body selector.
0:20
The .car selector is called a class
selector.
0:21
And when you look into the HTML document
for
0:24
the class car, you find it here in our
image tag.
0:27
Because the class selector car is more
specific,
0:32
than just anything inside the body.
0:36
I could technically, put this whole bit of
code above the body, and
0:39
everything should work out exactly the
same.
0:44
So, I'll save it out, and refresh the
page, and nothing's changed.
0:47
I'll put it back where it was, just so
0:53
I keep everything in the right spot, and
don't get confused later on.
0:56
But keep in mind, that if you have a more
specific selector rule,
1:00
like a class selector it's going to
override a more general selector rule,
1:04
like element selector no matter what the
position.
1:09
That about wraps it up for our style
sheet.
1:14
Keep changing things to make it your own.
1:17
Also, try writing in some new rules under
each selector.
1:19
After a quick quiz, we'll be diving into
what JavaScript is, and
1:23
how it's going to help our buttons make
sounds?
1:27
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up