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 trialBryan Brewer
9,830 Pointshow do I change color element of a h1 tag without there being a code already in place ,
I have changed the tag to a h1 then gone to the styles page to set color element it looks something like this
<body>
<h1> "welcome to my web page"</h1>
<h1 class="welcome to my web page"/h1>
</body>
then on styles page I done this
.welcome to my web page{ color:purple; } she did not explain how to do with no code already in place ,not sure what I am doing wrong could someone help please
<!doctype html>
<html>
<head>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<h1>Welcome to My Web Page!</h1>
<h1 class="Welcome to My Web Page!"/h1>
</body>
</html>
. Welcome to My Web Page!{
color:white;
}
3 Answers
Dana Al Taher
Courses Plus Student 9,499 PointsTry changing it to this:
<!doctype html>
<html>
<head>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<h1>Welcome to My Web Page!</h1>
<h1 class="WelcometoMyWebPage">Welcome to My Web Page!</h1>
</body>
</html>
and
.WelcometoMyWebPage{
color:white;
}
This is removing the spaces in the class name and also removing the exclamation mark. In addition, the opening and closing tags of the h1 element were not separate, the text you want to present as a heading has to be between both tags like such:
<h1 class="ClassName">Text you want should be in here.</h1>
I hope this helps you!
Camille Sébastien Niessen
2,653 PointsYour classname contains spaces, so every word is a different class. Call your class something like class="h1_welcome" & call it in CSS with .h1_welcome
I guess that will fix it :)
Camille Sébastien Niessen
2,653 Pointson this website you can find more information about classes.
Jason Anders
Treehouse Moderator 145,860 PointsHey Bryan,
I'm not sure why you are adding a class to the <h1> tag? The challenge task simply states to "Change the color of the h1 tag to purple." It doesn't say anything about adding a class. So, all you need to do (in the CSS file) is target the <h1> and change the color.
Below is the corrected rule needed. Have a look:
h1 {
color: purple;
}
Keep Coding! :)
Kristopher Van Sant
Courses Plus Student 18,830 PointsKristopher Van Sant
Courses Plus Student 18,830 PointsHey there! I moved your answer to the answer section so that it can be voted on by fellow students and potentially marked "Best Answer". Happy Coding!