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 trialAbhijit Das
5,022 PointsI want to add a back ground color of header
Hi friends, Just out of curiosity, I want to add a default background color on my header class on document load..it seems it's not happening here, pls help me. Thanks
2 Answers
Tsenko Aleksiev
3,819 PointsAaaaa,
.header{
background-color: red; //for example
}
Is this what you want? Post your code to check it.
Jordan Watson
14,738 PointsHi Abhijit Das,
There are a few ways you can do this on is by adding an inline style directly on to the
<header style="background-color: dodgerblue;"></header>
element or add a style within the head of the document
<style>
header{background-color: dodgerblue;}
</style>
or you can do it the most common way which is include it in an external style.css file which you can include in the head also
<link rel="stylesheet" type="text/css" href="css/style.css" />
But going but what you are asking adding the a style directly to the element will ensure that the background color will be applied as soon as the page starts to load.
Abhijit Das
5,022 PointsHi Jordan Watson thank you for your reply...with that background-color; I have to declare height for getting the BG color.
Abhijit Das
5,022 PointsAbhijit Das
5,022 PointsI did that already Tsenko Aleksiev still it's not reflect on the page. Later i figure out that i have to put height for header element as well..Thank you for your reply.