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

Jenny Suh
Jenny Suh
200 Points

help with .main-pg set to paragraph class

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

    <p> <h1 class=".main-pg"</h1>

   My amazing website</p>

  </body>
</html>
styles.css
<p> class=".main-pg"{

} 

2 Answers

Steven Parker
Steven Parker
231,268 Points

You've got the class part right, but you have parts of another element there also (h1). The class setting should go right after the "p" inside the "<p>" tag :point_right: <p class=".main-pg">

And nothing goes yet on the "styles.css" tab. When it does, the syntax will be different.

When creating a class for an HTML element make sure to leave out the '.' when defining the class so for example:

You're asking to have the .main-pg set to paragraph class so it should be <p class="main-pg"> and not <p class=".main-pg">

And then when you're creating a declaration on the CSS style sheet to refer to the class you created you don't need to include the carrots.

To refer to a class element you simply just need to put the '.' to refer to any class created.

So it would be .main-pg

Steven Parker
Steven Parker
231,268 Points

Jenny Suh — Glad to help. You can mark a question solved by choosing a "best answer".
And happy coding!