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 trialPatty Bedard
44 Pointshow do I set color for an h1 tag
I am trying to add a color to an h1 tag in css
<!doctype html>
<html>
<head>
<h1 class = "tag name"> Hello, Patty Bedard. </h1>
<link href="styles.css" rel="stylesheet">
</head>
<body>
<p>Welcome to My Web Page!</p>
</body>
</html>
3 Answers
Marco Koopman
5,290 PointsYou can use:
h1{ color: <set color here>; }
or you can add a class to your h1 like <h1 class="header"></h1>
Then you can use:
.header{ color:<set color here>; }
Also you need to place your <h1> in your <body> and not your <head>.
Have fun coding :)
Alexander Davison
65,469 PointsFirst, you must change the p
element to a h1
element :)
Good luck! ~alex
Julien riera
14,665 PointsHello,
As written above, your whole content should be wrapped in your body tags. You never use the head tags for content for say.
However, if you're using a CSS file beside to style your content, you have to add it in your <head> with a tag looking like this:
<link rel="stylesheet" type="text/css" href=" YOUR_FILE_NAME.css">
In this case, YOUR_FILE_NAME.css must be in the folder where your index.html is. If you're using a workspace, just create a file .css without putting it in a folder.
Hope this helps !
Julien