im trying to stretch a div across a page. its gonna be 100% wide but when i put it in. the left and right still have white space. what do i do?

1 answer

3
points
This was chosen as the best answer

You have to set the body to have no margin. Generally, the padding is set to "0" as well. A lot of times this is done with a CSS reset or reboot file. You can find one here.

To get your 100% width to work use this CSS:

body{
    margin: 0;
    padding: 0;
}
#div{
    width: 100%;
    margin: 0px;
}
Answered almost 7 years ago by David Leininger
  • Note: ANY parent object (body, layout/wrapper divs, etc.) with padding/margin applied will need to have zero right/left values as well in order to achieve 100% browser width. Gary Hepting almost 7 years ago
  • Right on the money, David. +1 Abinadi Ayerdis almost 7 years ago