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

Danilo Correia
Danilo Correia
294 Points

colour h1 tag

I can't turn it green

index.html
<body>
  <style>
    h1{
      colour: green;

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

I'm going to have to check this, but I believe that the <style> tag should be in the <head> section, not the <body>. I'll confirm this once I check it out!

1 Answer

Petar Zelenovic
Petar Zelenovic
11,356 Points

First, your <style> tag needs to either be in the head section of the html, or the style should be embedded in the tag, or most preferred way - it should be in an external stylesheet.

Anyhow, here's an example of the code you need to use if all in single page:

Please note that you also need to spell 'color' rather than 'colour'

<!DOCTYPE html>
  <html>
    <head>
      <style>
        h1{color: green;}  
      </style>
    </head>
    <body>
      <h1>Nick Pettit</h1>
    </body>
  <html>

** MOD note: Moved from "comment" to "answer" so it may be up-voted or picked as "Best Answer" Jason