Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

HTML Introduction to HTML and CSS Getting Familiar with HTML and CSS Test: Changing the Look of a Web Page

Aidan Robertson
Aidan Robertson
936 Points

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.

Aidan Robertson
Aidan Robertson
936 Points

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.