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.

CSS Unused CSS Stages Media Queries Adaptive Layouts with Media Queries

Matt Caron
Matt Caron
2,212 Points

Need a refresher

Hey I'm stuck trying to understand something:

Why is it that I have to select .col instead of .content? Seems strange because col is preceded by main, secondary, and extra in the HTML.

So it looks like this:

<div class="main col">

1 Answer

Janek Rezner
Janek Rezner
12,973 Points

if you were to select .content you would end up floating the parent of .col elements and not .main, .secondary and .extra themselves (as they are nested inside it).

also by passing 2 words as a class you are giving 2 autonomous classes to one element (you can give multiple classes to one tag but only one id).

So this code -

@media screen and (min-width: 481px) {
    .col {
        float: left;
    }
}

is exactly the as this -

@media screen and (min-width: 481px) {
    .main, .secondary, .extra {
        float: left;
    }
}

and they both let you pass the challenge.

but this:

<div class="main col">

is one div with two classes

1) .main

2) .col