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

Leo Marco Corpuz
Leo Marco Corpuz
18,975 Points

Using .col as a selector instead of .primary-col and .secondary-col

I'm wondering why it wouldn't work to use .primary-col,.secondary-col as selectors to make the columns.I've tried it and nothing works on the paragraphs.

Gabriel Plackey
Gabriel Plackey
11,052 Points

Could you post your code to look at?

4 Answers

Steven Parker
Steven Parker
220,634 Points

If you're using the code from the video, there aren't any classes named "primary-col" or "secondary-col" used in the HTML.

But you should be able to get the same results using ".primary, .secondary" as the selector.

Luke Kennedy
Luke Kennedy
11,661 Points

Hi Steven,

Thank you for this! I was confuse for a while till you mentioned that we could also produce the same result with '.primary, .secondary'. This was a tricky challenge, helped me remembered that we can actually give 2 names of class to the tags.

So kind of you to help out, I literally see you in almost all the questions posted by other students. haha

Luke.

This is how I went at it :

.primary { width: 50%; display: inline-block; float: left; padding-right: 10px; }

.secondary { width: 50%; display: inline-block; float: right; padding-left: 10px; }

Worked for me. Would there be an unintended consequence I didn't see ?

William Coshburn
William Coshburn
6,125 Points

Wait, it says "primary col" so why can't I write " .primary col" ?

Steven Parker
Steven Parker
220,634 Points

You need periods before class names in a selector, and no space if they pertain to the same element. So you could write ".primary.col", but it's excessive specificity (not "best practice").

William Coshburn
William Coshburn
6,125 Points

Thank you. I didn't realize the space was an issue.