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 change the color of an HTML tag?

Can I get help with the above task

2 Answers

Robert Lanchsweerdt
Robert Lanchsweerdt
3,943 Points

Best practice is creating a CSS and then referencing the HTML element (ideally with a class or tag) to change the color. If you want to change the text, then you'll list "color" within the elements brackets. If you want to change the background color, then it'll be the "background-color."

For example, you want to change the color of an H1 tag with the class "title", you'd write in the CSS:

.title { color: blue; }

You may also change HTML color using inline styling. For example, you want to change the color of an H1 tag, you'd write:

<h1 style="color: blue;">Hello World</h1>

Here's a link for more details about inline styling: https://www.w3schools.com/html/html_styles.asp Here's a link about CSS styling: https://www.w3schools.com/css/css_text.asp

I hope this help you :)

~ Rob

Ezra Siton
Ezra Siton
12,644 Points

Not html, H1. By CSS.

h1{
   color: purple;
}
Tim Strand
Tim Strand
22,458 Points

be aware also that color = text color, background-color = tag background color