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 trial

CSS CSS Layout Basics Getting Started with CSS Layout Creating a Sticky Footer

STICKY FOOTER

If we didnt wrap the header would it affect anything? I learned from mr gil hernandez to never wrap the header and the footer.

3 Answers

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

You can create a div container (in this case named wrap) that will wrap around all the content (that means the header aswell) except for the footer, so that you have a fixed height on your content that therefore will push the footer down and keep it stuck there, regardless of the amount of content above it. That's why it's referred to as a "sticky footer".

I dont like wrapping my headers and footers so I just wrapped the main content and made the vh value smaller

<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Best City Guide</title> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/style.css"> </head> <body> <header class="main-header"> <div class="container"> <h1 class="name"><a href="#">Best City Guide</a></h1> <ul class="main-nav"> <li><a href="#">ice cream</a></li> <li><a href="#">donuts</a></li> <li><a href="#">tea</a></li> <li><a href="#">coffee</a></li> </ul> </div> </header> <div class="wrap"> <div class="container"> <h2>Welcome!</h2> <p>Everything in this city is worth waiting in line for.</p> <p>Cupcake ipsum dolor sit. Amet chocolate cake gummies jelly beans candy bonbon brownie candy. Gingerbread powder muffin. Icing cotton candy. Croissant icing pie ice cream brownie I love cheesecake cookie. Pastry chocolate pastry jelly croissant.</p> <p>Cake sesame snaps sweet tart candy canes tiramisu I love oat cake chocolate bar. Jelly beans pastry brownie sugar plum pastry bear claw tiramisu tootsie roll. Tootsie roll wafer I love chocolate donuts.</p> </div> </div>
<footer class="main-footer"> <span>©2015 Residents of The Best City Ever.</span> </footer> </body> </html>

/*****CSS*********/ .wrap { min-height: calc(65vh - 89px); }

What are you trying to do? Please post code.

I finished with what I was working on. I dont need help anymore. Thank you. The code is below tho.

<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Best City Guide</title> <link rel="stylesheet" href="css/normalize.css"> <link rel="stylesheet" href="css/style.css"> </head> <body> <header class="main-header"> <div class="container"> <h1 class="name"><a href="#">Best City Guide</a></h1> <ul class="main-nav"> <li><a href="#">ice cream</a></li> <li><a href="#">donuts</a></li> <li><a href="#">tea</a></li> <li><a href="#">coffee</a></li> </ul> </div> </header>

<div class="wrap">

<div class="container">
  <h2>Welcome!</h2>
  <p>Everything in this city is worth waiting in line for.</p>
  <p>Cupcake ipsum dolor sit. Amet chocolate cake gummies jelly beans candy bonbon brownie candy. Gingerbread powder muffin. Icing cotton candy. Croissant icing pie ice cream brownie I love cheesecake cookie. Pastry chocolate pastry jelly croissant.</p>
  <p>Cake sesame snaps sweet tart candy canes tiramisu I love oat cake chocolate bar. Jelly beans pastry brownie sugar plum pastry bear claw tiramisu tootsie roll. Tootsie roll wafer I love chocolate donuts.</p>
</div>

</div>

<footer class="main-footer">
    <span>&copy;2015 Residents of The Best City Ever.</span>
</footer>

</body> </html>

/*****CSS*********/ .wrap { min-height: calc(65vh - 89px); }

yes, i dont like using the body element as a wrapper because if you want to give your full page a background color or image (or just any style) youll need to add it to the html element since its parent of the body and the root of the document. also if your site has elements that need to be placed outside of the wrapper, then it would not be appropriate to add them outside the body

Jamie Reardon
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Jamie Reardon
Treehouse Project Reviewer

That is true, however you don't wrap a div around the body tag if you want to create a sticky footer.