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

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

I'm having a hard time getting the h1 element to green

This is what I have, but I'm not sure how to fix it

<body> <style> h1 { color:green; }

<style> <h1>Nick Pettit</h1> </body>

4 Answers

Hi Robert,

I copied and pasted your code into the code challenge and it worked. Be sure you are leaving the style element tags in place from the previous challenge.

Jeff

<style>
    h1 { color:green; }
  </style>

/* Or better yet: */

<style>
    h1 {
      color:green;
    }
  </style>
James Barnett
James Barnett
39,199 Points

Jeff Busch -

> Or better yet

I would beg to differ, CSS rules that have only one property should be on 1 line for maximum readability.

However, that's neither here nor there for Robert Anderson whose trying to right his first rule CSS.

Ruben Leija
Ruben Leija
4,051 Points

I am not sure how your html code looks like. But theirs a couple things I can think of that could be causing the problem.

  1. Your CSS is not linked to your html page
  2. You dont have a h1 tag element on your html page

I think the problem is that it overlaps with another style for the h1 you're trying to change the color to. Try to specify a class like:

h1.class-name {
 color: green;
}

And then in the h1-tag <h1 class="class-name">Hello</h1>. If that works then the problem is that it you have already specified the color somewhere else in the CSS.

Thanks for the help everyone. I'm very new to this, so I appreciate the advice. I'll give it another shot at this challenge when I get home from my day job later tonight.