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

h1 tags

how do i change the color of an h1 tag?

2 Answers

Justin Olson
Justin Olson
13,792 Points

Good question. There are two common ways, one being more common. First, the least common, adding the style to the element tag directly.

<h1 style="color: red">Hello</h1>

This adds the color red to the H1, but isn't used that often due to simplicity. The preferred option is adding the color property to the tag within the CSS file.

h1 {
  color: red;
}

Again, both accomplish the same thing, but the bottom option allows you to add more, and not clutter up the html file.

Hope this helps out!

You'll want to swap to the 'style.css' , and then use the following:

h1 {
  color: purple;
}

Purple is the color they chose to use in the code challenge, but you can change it to almost anything! Hope this helps