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

**URL:** <https://forum.freecodecamp.org/t/is-it-unnecessary-to-add-width-100-to-the-block-level-elements/390858>\
**Category:** General\
**Created:** [May 18, 2020, 11:17pm UTC](https://forum.freecodecamp.org/t/is-it-unnecessary-to-add-width-100-to-the-block-level-elements/390858 "2020-05-18T23:17:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![CrockAlley](https://avatars.discourse-cdn.com/v4/letter/c/da6949/32.png) [@CrockAlley](https://forum.freecodecamp.org/u/CrockAlley)\
**Post date:** [May 18, 2020, 11:17pm UTC](https://forum.freecodecamp.org/t/is-it-unnecessary-to-add-width-100-to-the-block-level-elements/390858/1 "2020-05-18T23:17:26Z")

</div>

```auto
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?

---

<div class="post-metadata">

**Author:** ![Catalactics](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/catalactics/32/151364_2.png) [@Catalactics](https://forum.freecodecamp.org/u/Catalactics)\
**Post date:** [May 18, 2020, 11:30pm UTC](https://forum.freecodecamp.org/t/is-it-unnecessary-to-add-width-100-to-the-block-level-elements/390858/2 "2020-05-18T23:30:11Z")

</div>

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.

 ![image](https://global.discourse-cdn.com/freecodecamp/original/3X/5/3/535e585d40af9d89d0336b4eae98266cab705e2f.png)

---

<div class="post-metadata">

**Author:** ![DanCouper](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/dancouper/32/158608_2.png) [@DanCouper](https://forum.freecodecamp.org/u/DanCouper)\
**Post date:** [May 18, 2020, 11:43pm UTC](https://forum.freecodecamp.org/t/is-it-unnecessary-to-add-width-100-to-the-block-level-elements/390858/3 "2020-05-18T23:43:23Z")

</div>

You should be adding something like

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

```

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

> **[Box Sizing | CSS-Tricks](https://css-tricks.com/box-sizing/)**
>
> The box-sizing property can make building CSS layouts easier and a lot more intuitive. It's such a boon for developers that here at CSS-Tricks we observe

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [June 1, 2021, 6:53pm UTC](https://forum.freecodecamp.org/t/is-it-unnecessary-to-add-width-100-to-the-block-level-elements/390858/4 "2021-06-01T18:53:27Z")

</div>

Closed on June 1, 2021, 6:53pm UTC


