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

where do I write CSS to select h1 ?

The challenge is to write CSS to select h1, yet I'm not sure how. What should I write and where ?

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

3 Answers

Dean Osborne
Dean Osborne
3,775 Points

Hi Arcel,

From your code it looks as if you are required to use internal styling for this challenge, see below for the solution to the challenge.

<head>
  <style>
    h1 {
      PROPERTY: VALUE;
    }
  </style>
</head>
<body>
  <h1>Nick Pettit</h1>
</body>

Within the <style> tags i have written h1 before the curley braces, this is known as the selector.

I hope this helps you.

Thanks, I thinked it work.

Nick Hooper
Nick Hooper
7,188 Points

Styles can be defined in 3 ways:

Inline - using a style attribute in HTML elements.

Internal - using a <style> element in the HTML <head> section.

External - using css files.

The best way is the external method by adding the style to the corresponding css file.

//Inline Example, put this in the element itself
<h1 style="Your css styles goes here">Nick Pettit</h1>


//Internal Example, put this in your html file
<style>
h1 {
//Your css styles goes here
}
</style>


//External Example, put this in your css file
h1 {
//Your css styles goes here
}

//Don't forget when using external css files you must make a link to it in your html file!

<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>

Thanks I might experiment with that one.

If it's asking you to write it in the css file then write

h1 {
// Your css styles goes here
}