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

how do i make a css element hit the h1?

i dont understand how top make the css element hit the h1

index.html
<body><style>{color:blue;}
  <h1>Nick Pettit</h1></style>
</body>

Hi Noah, to select an h1 in css:

h1 {
  // css code to be applied to the h1
}

Hope this helped!

2 Answers

You need to either add it inline like so

<h1 style="color:blue">Nick Petit</h1>

Or using a selector in the style section of your page

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

By the way your style section should be in the head section of your document.

Ryan Field
PLUS
Ryan Field
Courses Plus Student 21,242 Points

A CSS declaration requires two things: the element that you are targeting and the styles that you wish to use on the target. To target and style an h1 element, you do this:

h1 {                  /* First declare the element (you may have to get more specific, depending) */
  color: blue;        /* Then, add your declarations inside the curly braces. */
}