Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

Claire Kao
Claire Kao
4,393 Points

class name

In the flexbox order video, the class name that is used in CSS is "item-1" but in HTML it's "item-1 item". Why is it that?

1 Answer

devvoyage
seal-mask
.a{fill-rule:evenodd;}techdegree
devvoyage
Front End Web Development Techdegree Student 14,257 Points

Hi there, Claire Kao!

I would look through the CSS file and see if there's another class just called ".item". Any element on the page can have more than one class. Multiple classes are listed separated by a space. So for instance, let's assume we have a div. We might see HTML that looks like this:

<div class="blue-back light-yellow-text">
    <p>Hello!</p>
</div>

And part of our CSS file might look like this:

.blue-back {
    background-color: cornflowerblue;
}

.light-yellow-text {
    color: cornsilk;
}

This means that the div will get both of those styles applied and have a background color of medium colored blue and text that is a light yellowish color.

In fact, we could add a third class to that. Let's assume that we're going to add another text color. This is where the "cascading" effects of CSS would take place. It is the last rule in the CSS file that will take precedence.

<div class="blue-back light-yellow-text pink-text">
    <p>Hello!</p>
</div> 

And we have the following CSS:

.blue-back {
    background-color: cornflowerblue;
}

.light-yellow-text {
    color: cornsilk;
}

.pink-text {
    color: palevioletred;
}

It might be tempting to think that because the light-yellow-text is listed first in the HTML that it is the one that will be applied. However, it is the last rule written in the CSS that will be applied. So, in this instance, you will have a medium color blue with a dark pink text.

Hope this helps! :sparkles:

Claire Kao
Claire Kao
4,393 Points

Thanks for the explanation!