#Questions about margin
7 messages · Page 1 of 1 (latest)
Hi Amber! By default all elements have some padding and margin, to solve it you can 'reset' those values with this code:
* { padding: 0px; margin: 0px; }
Thanks Maria, this answer helps a lot, but i still have some confusion. If all the elements are inside "body", why their margin can be outside "body".
This is because the body element has a default margin of 8px, see also https://stackoverflow.com/questions/13127887/how-wide-is-the-default-body-margin
Thanks BK. But i have already set the body's margin to 0px. I found that the margin is caused by h1 element inside the "div" element. I cannot figure out why.
Ah sorry, I thought you were asking why the body has a margin. Try adding border: 1px solid black to your container, or better yet, add it to the universal selector * { } so you can see the margin/padding of every element to figure out where the extra margin is coming from
It could also be related to margin collapse, since every element has its own margin, I suspect the .container margin might be collapsing with the .image-container margin
