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

How do I add the property to change the color of the H1 to purple

Im new to this...

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

    <h1 color=purple>Welcome to My Web Page!</h1>

  </body>
</html>
styles.css
body,

  <h1>color=purple</h1>

To target your h1 element in CSS, you just need the h1 tag by itself, and then whatever property you want. For example, this is what your style.css should look like:

h1 { color: purple; }

The color property can be on it's own line, but make sure you have the opening and closing brackets, as well as a semicolon after each property.

2 Answers

Christopher De Lette
PLUS
Christopher De Lette
Courses Plus Student 7,139 Points

Hi Aidan,

In your previous post myself and one other community member answered this question without giving the direct answer. I think this is the best way to learn any new subject, especially coding. We are more than happy to help and to get you going i'll post the answer. Keep trying and researching and you'll definitely get the syntax/lexicon/semantics :)

h1 {
  color: purple;
}

Take care and Happy Coding!

BTW if you are stuck please continue to use the community as we are here to assist.

I kinda figured as the two answers got me closer to the finish, I was just totally lost on the official format as Ive forgotten the proper semi-colons and the likes ha! Thanks :)

Brandon Benefield
Brandon Benefield
7,739 Points

The proper way to do this is in your CSS. Target your h1 tag and set the color property to purple.

h1 {
color: "purple";
}

You should only have one h1 tag per html page. So until you get into something more advanced, there is no need to add a class or id to any h1 tag. Someone can correct me on that if I am wrong.