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

Can't get div to span full width

Hi all,

here's the very simple code I'm working on but this will still result in the .container div leaving a white line on the left and top…if I use static or relative positioning the white line is on the right too, as if there was padding on the body element – and that's that's why I put padding:0; on both html and body…but still nothing.

What am I doing wrong?

4 Answers

You need to put 0 margin on the body.

Even better would be to use normalize.css. It's essential for cross browser compatibility.

You removed padding from the body but you forgot about margin.

Right! Thought that it was default...Thanks so much!

Luca Sorgiacomo - You thought what was the default? normalize.css? margin: 0 on body?

I meant the margin: 0 on body

Set the body margin to 0px

An other good idea is set all the elements to 0px.

example:

  • { padding: 0px; margin: 0px; }

Peter Hatzer - A much better choice is to use normalize.css. Here's a great article about the downsides of using a universal selector for a reset.