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

How do you add a class to the paragraph element?

I'm not sure how to add class "main-pg" to the paragraph element? Is this done in html or the css page?

3 Answers

<p class="classNameHere" id="idNameHere> Your Text </p>

this will allow you to style them in css

.classNameHere {
    yourstyles 
}

#idNameHere {
    your styles
}

<!doctype html> <html> <head> <link href="styles.css" rel="stylesheet"> </head> <body> <p>My amazing website</p>

</body> </html>

Thanks so much for the response! Im still not sure where it goes in the code. Do i create a new paragraph or add it to the existing one?

Julian Gutierrez
Julian Gutierrez
19,325 Points

Add it to the existing paragraph. the syntax is as follows:

<p class="put your class name here">My amazing website</p>

Thank you for the response!

Hi Stephen, you can assign the value of the property ("main-pg" in your case) to the property ("class" in your case) by using this format:

<p property = "property value">  </p>

Thank you for the response!