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 Introduction to HTML and CSS (2016) Getting Familiar with HTML and CSS Test: Changing the Look of a Web Page

I can't get Task 2 as a Beginner

Change the color of the h1 tag to purple — you can do this by creating a h1 selector and setting the color property to purple.

 I just can't get, i tried still yet could not get it
index.html
<!doctype html>
<html>
  <head>
    <link href="styles.css" rel="stylesheet">
  </head>
  <body>


    <h1>Purple</h1>
    <p class="tag location"> purple </p>


  </body>
</html>
styles.css
.tag {
  background-color: Blue;
Pavol Kocalka
Pavol Kocalka
9,961 Points

Hello,

  1. If you want to change h1 tag text to purple, you need to set class on tha h1 tag. You set it on <p> class instead.

  2. Do not forget to add closing } in .tag declaration.

  3. You used background-color CSS declaration which sets background. You need color css property to set color of the text.

Here is my suggestion html:

<!doctype html>
<html>
    <head>
        <link href="styles.css" rel="stylesheet">
    </head>
    <body>
        <h1 class="tag">Purple</h1>
        <p>Some paragraph text if you want to have paragraph under heading.</p>
    </body>
</html>

and css

.tag {
    color: purple;
}

1 Answer

Tobias Erich
PLUS
Tobias Erich
Courses Plus Student 2,980 Points

You can do this on a lot easier way. For the <h1> element you don't need a class attribute. For Example:

<!doctype html>
<html>
  <head>
    <link href="styles.css" rel="stylesheet">
  </head>
  <body>

    <h1>Welcome to My Web Page!<h1>

  </body>
</html>

This is your Challenge HTML code.

If you change the CSS to the following code, you solved the Challenge.

h1 {
color: purple;
}

You can change the color of the elements whithout any class tag. If you have more than one <h1> element on your Website and you want any <h1> tag in a different color you need different classes for them to change the color seperatly. Else you don't need a class attribute, because you only have one <h1> element on your Website.