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

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,064 Points

Could you post your code to look at?

4 Answers

Steven Parker
Steven Parker
231,236 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
231,236 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.