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

What is the formula for creating a 'class' tag within a paragraph and giving it a name (such as "main-pg")?

I need help ASAP! I need to wrap a chunk of text in a 'class' and give the class a name for the purpose of CSS styling. What is the formula for this tag?

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

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

  </body>
</html>
styles.css

3 Answers

Hey! See my updated answer above. Replace the dummy text with your actual values and you should be fine. Make sure you don't add spaces around the equals sign. class="main-pg" will pass but class = "main-pg" will fail.

Good luck!

It worked perfectly! Thanks again.

Hey! Replace the space with = and remove the class tags, like so:

<p class="whatever">Lorem ipsum</p>

EDIT: The inline css class is an attribute which you include in your opening HTML tag. Just like the src attribute of the <img> tag or the href attribute of the <a> tag.

Hope this helps!

Thank you!

I tried this: <p><class = "main-pg"> My amazing website </class></p> but it still didn't work... where else could I be going wrong?

brandon downs
brandon downs
11,577 Points

class is not a tag, it is know as an attribute. you can use attributes inside of different element tags such as <p class='main-pg'>My amazing website</p>

there are many different types of attributes, some other common ones you may have seen included in element tags are id | src | alt | href

here is some info I pulled from w3schools

  • All HTML elements can have attributes
  • Attributes provide additional information about an element
  • Attributes are always specified in the start tag
  • Attributes usually come in name/value pairs like: name="value"

https://www.w3schools.com/html/html_attributes.asp