Don’t Fear Specificity Targeting Content with Classes & IDs

We’ll give you the low-down on Classes and IDs and hone your CSS skills at the same time.

In this episode, Russ introduces you to classes and IDs, explains the levels of specificity with HTML markup and CSS, and get you psyched to use your hypothetical label maker all over the internet.
For further reading, check out this article by on Smashing Mag as well as this article on HTML Dog and definitely do a lot of poking around on your favorite sites to see how elements are targeted on them!
  1. Thanks so much Russ! Being that the first CLASS demonstration targeted the generic menu pricing, I’m a bit confused about class = price. I’m sorry to be such a literalist, but I’m trying to wrap my brain around something … here goes:

    In the second Class demonstration, the word “price” was used to recolor “Northeast Kingdom.” Had it been the other way around — northeast kingdom instead used to demonstrate changing the color to the cool red — would the term still be “price” used to recolor the menu pricing? In other words, as # just means “ID of”, does . (dot alone) just mean “Class of”? Or must the . (dot) always have “price” after it?

    • Hey Kat,

      The “.” just means “Class of” and you can put any string of letters after it you like! There’s nothing magical about the word “price” it’s just what I personally decided to call that particular class because it had meaning for me (since I was using it on the prices in the menu). In other words, I could have also used the words “cost”, “chunk-of-change” or “sjfelijenfieijf” if I wanted to. Using “price” helps me remember what piece of content the class was for.

      I applied the class “price” to the title of the page just to demonstrate that any element with the class of “price” will have the CSS rules associated with the class “price” applied to it. You’re essentially naming a set of CSS rules (“price”) and then applying that name wherever you want those rules to be applied.

      Hope that helps!

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>