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 trialAtul Varma
4,285 PointsHow to change the color of h1 tag in the challenge task 2 of 2 of HTML and CSS ?
Where am I supposed to make a change in the code..?
<!doctype html>
<html>
<head>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<h1 class: "tag">Welcome to My Web Page!</h1>
</body>
</html>
.tag {
color: purple;
}
3 Answers
Mike Hickman
19,817 PointsHi Atul,
You're close, but you need to change a couple things. In the first task, you just needed to change <p> to <h1>. You don't need to add a class for either of the two exercises.
In your css, now you just need to select the h1 (instead of .tag) and your code will work.
Good luck!
Mike
-- --
12,382 PointsHi Atul!
For this challenge, you have to apply the style to the <h1> tag. You don't have to give the h1 a class / an id to do this - you can style tags in the css by simply stating the tag type.
<h1>This is an H1</h1>
h1 {
color: purple;
}
If you want to apply a class or an id to an element and style it, you can do so like this:
<div class="divClass">A div</div>
<div id="divId">Another div</div>
.divClass {
color: red;
}
#divId {
color: green;
}
But you don't have to do this for this challenge. :)
Darren Joy
19,573 PointsNot sure which way is the right way for the exercise in question.. but from what you posted it looks like you are trying to use a class to change the color in the h1 tag. You can add classes to html elements like so:
<htmlThang class="className">blah blah some text here</htmlThang>
note that the className is the same as the name used in the CSS part, but without the . (dot)