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

Meenakshi Bohra
Meenakshi Bohra
1,182 Points

how to set the color of the h1 element to green

how to set the color of the h1 element to green

index.html
<body>
  <style>
    <h1> {
      color : green ;
    }
    </style>
  <h1> meenakshibohra </h1>
</body>

3 Answers

highlandcow
highlandcow
7,352 Points

You select elements without <> when defining a CSS rule.

So instead of...

    <h1> {
      color : green ;
    }

...you'd do...

h1 {
      color : green ;
    }
Matthew Rigdon
Matthew Rigdon
8,223 Points

You want to modify the color of your text inside of the CSS file, not the HTML document. This is good practice. Inside the CSS document, you write:

h1 {
  color: green;
}

This will set all <h1> tags to have a text color of green.

Christopher Carrasco
Christopher Carrasco
20,679 Points
<style>
   h1 { color: green; }
</style>

<body>
   <h1>Text in here should be green</h1>
</body>

** style element should not be inside the body element, but rather before it. Also the '<>' surrounding the h1 shouldn't be used when styling the h1 element, but It IS needed inside the body element.** Hope this makes sense.