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 trialSherman Hightower
3,294 PointsHow to change the <h1> color?????
The class dose not show you how to do it.
3 Answers
Jennifer Nordell
Treehouse TeacherHi there! Depending on your use case, you can change the color of an h1 tag using either a class selector as shown in the video or a type selector. Here's an example of both:
/* Class Selector */
.name {
color: green;
}
/* Type/Element Selector */
h1 {
color: green;
}
If you're keen to learn more about CSS selectors checkout our CSS Selectors Quickstart course.
I hope this helps!
ethan moffat
251 PointsHi, changing colours is super easy.
<div class="my_container">
<h1>Hello world!</h1>
</div>
.my_container h1{
color: black; /* or hexidecimal */
}
There are alternatives to doing this.
You can assign a id or class to the h1 directly & call it in the stylesheet or you can do direct styles to the h1 tag
<h1 style="color: #eee;">Hello world!</h1>
Carlos Martinez
10,660 PointsYou are missing a semi-colon after black.
ethan moffat
251 PointsGood eye, I am so used to text editors auto completing them :P
Carlos Martinez
10,660 PointsHaha true!
Trần Phúc
2,264 Pointsif you want change to blue
<h1 style="color:blue;">This is a Blue Heading</h1>
mohammed qadi
852 Pointsmohammed qadi
852 Pointsim sorry but i really didnt know where to write that code if its writen in css it didnt work for me
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi, mohammed qadi! If you mean for the challenge at the end of this series, you'll find two tabs in the challenge. One is
index.html
and the other isstyles.css
. Your code should go in thestyles.css
tab.mohammed qadi
852 Pointsmohammed qadi
852 Pointsok thx i just messed up with some code i found online , i deleted it and it worked thx anyways and thx for the super quick response :)