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!
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

Jennifer Hinkle
8,365 Pointsbackground color height
Hello,
I have a container div with very few elements in it so the content ends about half way up the viewport. Therefore, the background color ends at the bottom of my elements. Is there a way to get the div to fill the entire height of the browser so the background color fills the entire viewport?
html
<!DOCTYPE html>
<html>
<body>
<div class="container">
<p>Hello World!</p>
</div>
</body>
</html
CSS
.container {
background: tomato;
overflow: auto;
width: 100%;
height: 100%;
}
Thanks for any tips! Jenn
3 Answers

James Anwyl
Full Stack JavaScript Techdegree Graduate 49,959 PointsHi, Have you tried setting the background on the body element? for example:
body {
background: tomato;
}

James Anwyl
Full Stack JavaScript Techdegree Graduate 49,959 PointsTry this:
.container {
background: tomato;
width: 100%;
height: 100%;
}
html, body {
margin: 0;
height: 100%;
}
Hope it helps!

Jennifer Hinkle
8,365 Pointsperfect! thanks so much for the tip!!

James Gill
Courses Plus Student 34,935 PointsJennifer,
Try changing "height" to "min-height", or applying color to the html or body tags.

Jennifer Hinkle
8,365 PointsThanks for the advice! But I'm applying the background color to the container instead of the body because I'm have the body act as a white border around my container. Also, maybe I'm using it wrong, but
min-height: 100%;
didn't change anything for me ...