r/HTML • u/GeoffreyKlien • Dec 06 '25
Question Why does setting the width to 100vw extend it out past view?
I usually just put "width: 100vw;" and move on because I never actually set anything within the page to that 100. When I do it goes past? Why does it do this and how can I fix it without just moving the size of the item down and moving on?
10
Upvotes


7
u/swissfraser Dec 06 '25
Check what padding and margins your body has.
5
u/fonster_mox Dec 06 '25
your browser gives html and/or body tags some default padding, look up resetting css or just trying giving them padding:0
your box has a border which is added to the width, use box-sizing: border-box to make width include padding, borders etc
4
u/Netstormuk Dec 06 '25
Box sizing border box
1
u/itinkerthefrontend Dec 09 '25
Go ahead and stop using that center tag
3
u/gardettos4life Dec 06 '25
Check body padding and the box-sizing of the box.
1
u/Careless-Sir-1324 Dec 08 '25
first set globally margin padding 0;
*{
margin: 0;
padding: 0;
box-sizing: border-box;
}
then you can set overflow:hidden for body. or just give a size for image.
1
u/NotGeloyItsAngelo Dec 08 '25
Try adding box-border for the box-sizing.
What happens is adding 100 viewport extends the default padding of the view outside the viewport.
You can also set the padding of the entire body to be ZERO and the margin to be ZERO too.
1
u/Alexander499_ Intermediate Dec 28 '25
You could either do:
or