Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

PHP Build a Simple PHP Application Creating the Menu and Footer Adding Active States to the Navigation

Boris Vukobrat
Boris Vukobrat
4,248 Points

HTML/CSS class attribute with few different names

Nice style.css we have here. I must say Randy pushes my limits at html/css knowledge mercilessly.

At this time I would like to clarify about class name definition that goes with two or more words. Like this one:

<div class="section shirts latest">

So how this works? I noticed .section.shirts selectors in css, but there is no "latest" anywhere?

2 Answers

Rick Yentzer
Rick Yentzer
5,885 Points

One of the purposes of different class names added to the same element is to apply different styles based on what the element is meant for. You will see this a lot as you progress in learning CSS. It's a way of creating common styling to elements with different needs.

<div class="notice alert">

and

<div class="notice warning">

Each of these would receive the same 'notice' style, but they would each receive the style associated with 'alert' and 'warning'.

Boris Vukobrat
Boris Vukobrat
4,248 Points

Yeah, I researched it already. Thanks. At first it looked like to me as one name with underscore missing : ). It isn't mentioned in previous css course. Now is simple, we can add several classes to the same element.

Didn't my answer helped you ? "... its another class in..."etc.. as its what i just said above : p .

Im just asking because I'm curious if you understood what i wrote : p or it was a bad explanation and bad show .

HI, did you finish the PHP course? if not , he will explain you how this works. Im pretty sure. Just stick with it and then if you feel your lost, re-watch all of it ( or most) and see how it works .

Boris Vukobrat
Boris Vukobrat
4,248 Points

Hi. Well of course I didn't finished it, I am just where above tags say.

This is new interesting css feature to me, and it is used a lot in this project. I don't have much of the css under my fingertips.

It seems to me these names are just alternative class names for same element. Why should we use more class names? Maybe for additional styling, as in the lesson

When you write like this , it means as i remember good, that its another class in it. Instead of writing class="x" class="y" etc.. you write class="x y" then you just style it e.g. y{ background:green; etc.. i think you will eventually get it after watching it . But watch with your mind on it. Don't fly away. Hope this helps.