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

anson liang
seal-mask
.a{fill-rule:evenodd;}techdegree
anson liang
Python Web Development Techdegree Student 5,319 Points

<style> .h1 { color: green; } </style> <h1>Nick Pettit</h1> i cant pass challenge task 3 of 3

<style> .h1 { color: green; }

</style> <h1>Nick Pettit</h1>]

with this code it said Bummer! Make sure you're coloring the h1

index.html
<style>
  .h1 {
    color: green;
  }


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

5 Answers

there are several kinds of basic CSS selectors: tag selectors, class selectors and id selectors.

This rule will select all h1 tags on the page:

h1 {

}

This rule will select all elements on the page that have a class attribute of class="first":

.first {

}

This rule will select all elements on the page that have an id attribute of id="new":

#id {

}

So, as you can see, you can tell if a selector is a class selector by a dot or period, and an id selector by a # sign.

h1 is a tag, so you need a tag selector in your CSS, not a class selector:

  h1 {
    color: green;
  }

The period in front of h1, .h1, makes it a class selector.

Tushar Singh
PLUS
Tushar Singh
Courses Plus Student 8,692 Points

When you choose a tag like a button, h1, img; You just name it in the css for the reference like this

h1 {
    color: green;
  }

.h1 mean you are selecting a class with a name h1, it will look like this

<h1 class="h1">Bla Bla Bla</h1>
.h1 {  /* . syntax for a class selector
    color: green;
  }

If its an ID selector

<h1 id="h1">Bla Bla Bla</h1>
#h1 {
    color: green; /* use # syntax for id selector
  }

Correct. But you would not want to use tag names like h1 in class or id attributes. Very confusing. Probably wouldn't pass verification. Not good style. But you have the idea.

Tushar Singh
PLUS
Tushar Singh
Courses Plus Student 8,692 Points

Ya I was just trying to demonstrate that by adding just a different symbol('#', '.'), everything changes !!