Is it unnecessary to add width:100% to the block-level elements?

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

footer {
  width:100%;
  background: #daad86;
  padding:30px;
  margin:20px 0 0 0;
}

This produces an unwanted horizontal scroll, presumably because it adds the padding to the overall width. Is it unnecessary to add width:100% to the block-level elements?

Hmmm… I don’t really know about this. But after checking it out. I just realized that they will actually fill up the whole container it is in, unless you specified. Huh, I guess I learned more everyday.

1 Like

You should be adding something like

*, *::before, *::after {
  box-sizing: border-box;
}

At the top of your CSS. Try that and the scroll behaviour should go

1 Like