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 trialMacy Morgan
1,948 PointsWhat 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?
<!doctype html>
<html>
<head>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<p><class "main-pg"> My amazing website </class> </p>
</body>
</html>
3 Answers
trio-group I.AM
25,713 PointsHey! 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!
trio-group I.AM
25,713 PointsHey! 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!
Macy Morgan
1,948 PointsThank you!
Macy Morgan
1,948 PointsI 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
11,577 Pointsclass 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"
Macy Morgan
1,948 PointsMacy Morgan
1,948 PointsIt worked perfectly! Thanks again.