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 trialnoah elramsisy
64 Pointshow do i make a css element hit the h1?
i dont understand how top make the css element hit the h1
<body><style>{color:blue;}
<h1>Nick Pettit</h1></style>
</body>
2 Answers
Preston Skaggs
11,818 PointsYou need to either add it inline like so
<h1 style="color:blue">Nick Petit</h1>
Or using a selector in the style section of your page
<style>
h1 {
color: blue;
}
</style>
By the way your style section should be in the head section of your document.
Ryan Field
Courses Plus Student 21,242 PointsA CSS declaration requires two things: the element that you are targeting and the styles that you wish to use on the target. To target and style an h1
element, you do this:
h1 { /* First declare the element (you may have to get more specific, depending) */
color: blue; /* Then, add your declarations inside the curly braces. */
}
Michael Newman
39,508 PointsMichael Newman
39,508 PointsHi Noah, to select an h1 in css:
Hope this helped!