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

Henry Salvador
Henry Salvador
152 Points

How do I write a CSS that will highlight h1 tag?

I am very confused by the meaning of the question

index.html
<body>
  <style></style>

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

3 Answers

rydavim
rydavim
18,813 Points

In this case, your CSS should go in between the style tags in the HTML document.

The challenge is asking you to select the h1 element using CSS in order to style it in the next step.

You select an element to be styled by writing it's name, followed by a set of curly braces.

<style>
  h1 {
    // Your CSS will go here.
  }
</style>
Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,858 Points

Hi Henry, The questions actually asks you to write CSS that will "select" (not highlight) the h1 tag. So in-between the style tags you just need to write out the selector CSS for the h1 tag:

h1 {}

Hope that clears it up for you :) Jason

Jieni Hou
Jieni Hou
5,136 Points

Hey Henry!

You've got 3 different options as in how to apply CSS styles to elements of HTML!

Internal Style (Embedded)

This is usually defined within your Head Tag in your HTML code.

<head> 
...
<style>
h1{
}
</style>
</head>

Inline Style

This will be styles applied directly to your elements! Remember that this style will be overriding your CSS modifications, so make sure to use this carefully.

<h1 style="color:purple;"> hello </h1>

External Style Sheet

This is what you should do for most webpages as you don't want to use either internal styles or inline styles to fill up your HTML code, making it long and hard to decode. All you have to do is to let HTML know to access the stylesheet that is within a certain file, and then HTML will use that document ( your CSS ) to style the elements on your HTML!

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

and then in your CSS file:

h1{
}

Remember that "main.css" is whatever the file name you gave to your css file, doesn't necessarily have to be "main". Good luck!