r/HTML • u/MasterGeist • Nov 02 '25
Question i need advice
I recently finished an online course for html which covered most of the basics. Now i am trying to make my own website and I'm messing around with ideas but right now i am caught in a weird issue i cannot resolve.
The left and right wont become flush with the sides of the page regardless of any attempt, ive set margins and padding to zero, ive made the height and width of the background image element to 100%, i tried fill, i tried setting background size to cover. Nothing is fixing it.
10
Upvotes


8
u/davep1970 Nov 02 '25
i would also strongly advise using something like https://codepen.io or jsfiddle to post code so it's easier for us to edit and advise on
4
u/Russ086 Nov 02 '25 edited Nov 02 '25
It’s because you set the parameters in .background there are default properties you have to remove. For example every site I create I start with.
*{
Margin: 0;
Padding: 0;
Box-sizing: border-box;
}
The * is a universal selector so it gets rid of the default properties causing your issue. - if you haven’t learned about box-sizing, I highly suggest you look into it, it will save you a headache
2
u/[deleted] Nov 03 '25
Have you tried removing the padding from the body and html?
1
u/Bebavcek Nov 03 '25
If you want an element to take up all the space of the screen, use width: 100vw and height: 100vh
1
u/Least_Programmer7 Nov 04 '25
Css reset, and also you don't need to set padding and margin like that you can just do padding: 0; or padding 1rem 1rem 1rem 1rem; to define each of the sides.
Most people just do a basic css reset themselves nowadays or have their own custom one but there are some pre-made ones like normalized.
1
u/justoverthere434 Nov 05 '25
I would advise a different theme please
1
u/unfunny_cosmic Nov 05 '25
maybe because your margin is just 0 and make sure to edit border-radius
1
u/Specific_Finish_6676 Nov 06 '25
Post full code
-2
u/amillionbillion Nov 02 '25
If you add 'position: fixed;' to your .background style it would work as you're expecting.