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

CSS How to Make a Website Beginning HTML and CSS Write a CSS Selector and Property

set the color of the h1 to green?

how do I add color to the h1 heading

index.html
<body>
  <style>{h1
  }</style>
    <h1>Nick Pettit</h1>
</body>

<style> body {background-color: green} </style>

damian celentano - He wants to target the h1 element, not the whole body, so that wouldn't work.

3 Answers

Hello Christopher :)

Inside your <style> tag you target the h1 element by using its name. It's that simple :) So basically in order to change h1's color to green you do the following:

h1 {
   color: green;
}

The curly bracelets are used for the code that will affect the h1 tag. So you put them after the "h1".

Sorry, i have read the question wrong.

<style> h1 { color: green; } (for the h1 background, you'd use "background-color", for the text it's the above.)

Sorry, i have read the question wrong.

h1 { color: green; } (for the h1 background, you'd use "background-color", for the text it's the above.)

Thank you for the headsup, K, i have just noticed.

Christopher, the syntax for inline styles is different from the syntax for internal and external css.

Since you're writing your CSS in the body tags, I'm not sure if you're trying to create an inline CSS style for H1, or if you're trying to create an internal style in the head of your document.

Here is a resource for you that explains the difference between each. http://www.w3schools.com/css/css_howto.asp