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 trialRach N
97 PointsHow do I change the color of an HTML tag?
Can I get help with the above task
2 Answers
Robert Lanchsweerdt
3,943 PointsBest 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
12,644 PointsNot html, H1. By CSS.
- H1 - the selector
- color - the property https://www.w3schools.com/cssref/pr_text_color.asp
- purple - value
h1{
color: purple;
}
- You find all colors names her (purple, blue and so on): https://www.w3schools.com/colors/colors_names.asp
Tim Strand
22,458 Pointsbe aware also that color = text color, background-color = tag background color