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

Martin Batista
Martin Batista
4,606 Points

In task 2, I typed purple in element H1's color property without quotes and it still didn't work. I'm confused...

Need a little guidance on task two. I believe I did it correctly but still getting error message. I'm not sure if I'm having connection issues. Not sure if I should've jumped ahead and put in CSS yet or not.

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

    <h1 class= "tag" color='purple'> Welcome to My Web Page!</h1>

  </body>
</html>
styles.css
.tag {
  background-color: purple;
  color: white;
  padding: 10px;
  border-radius: 5px;
  display: table;
  margin: 10px auto;

2 Answers

Erik McClintock
Erik McClintock
45,783 Points

Martin,

There are two different ways you could choose to tackle this type of situation, and either will work in this code challenge:

1) In the CSS file (you'll see a .css file in the two tabs just above the code in the challenge), you would target your h1 element, and then inside your code block, you'd list the color property and then set its color, as follows:

h1 {
    color: purple;
}

2) If you wanted to set the color how you're trying - that is, directly on the element in your HTML (which should be avoided, in general) - you would need to use the style attribute on your h1 element, then inside that attribute is where you would target and set your property.

<h1 style="color: purple;">Welcome to my web page</h1>

Happy coding!

Erik

Sean Kochel
Sean Kochel
1,693 Points

I'm new to this as well, but from the looks of what I see, your CSS may be overriding your 'purple' declaration. You are saying "use purple" in your HTML, and then saying color: white in your CSS, which would override the purple, I think