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

HTML Introduction to HTML and CSS (2016) Make It Beautiful With CSS Test: Styling by Element and Class

Here we go again, apparently I have no idea what class is still.

Every time I think I know what class is, a question will come to remind me I don't lol. It is saying to add a class called ''main-pg'' to the paragraph element.

index.html
<!doctype html>
<html>
  <head>
    <link href="styles.css" rel="stylesheet">
  </head>
  <body>

    <p>My amazing website</p>

  </body>
</html>
styles.css

I find it helpful to save and look at past examples. In this case, find your paragraph element <p>. You add the class by <p class="mainpg">. You just need to look at more example and practice it a few times.

2 Answers

Jacob Bergdahl
Jacob Bergdahl
29,118 Points

Whoa, Chandler! Easy with the language! I edited your post to remove the unnecessary stuff.

I recommend you watch the video before the challenge again. The videos usually do a great job in explaining concepts, but if you find them hard to understand, you might want to watch them twice, and even take notes while watching! In HTML/CSS, a class can be seen as an easy way of assigning the same style to multiple objects.

It was just a joke, I hope you saw the sarcasm in it and knew it was a silly quote. No curse words used. I'll watch it again, but please don't be upset with me.

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there again! Look, a class is just a way for you to put items in a group. And you could name class just about anything you want to be honest. So if you had a class named "chandlerRocks", you could use that class to set the background color to red. Now every element that has the class "chandlerRocks" would have a red background.

Generally speaking, we try to make our names something logical and memorable. Something that others can figure out if they're looking at our code. So here they're going to add the class main-pg to the paragraph. Which is good naming, because it has to be the main paragraph. It's also the only paragraph. Take a look here:

<p class="main-pg">My amazing website</p>

Keep in mind also that you can assign multiple classes to an element. Hope this helps! :smiley: