why is there white space on top even though I set body as margin 0 which will make everything in it with margin 0?
Off-topic question but when do we have to specify the width and height? I mean even if I don’t specify the distance, everything seems to be working all fine usually?
h1's top margin leaking through the
divs it’s in. Setting it to 0 should remove the white gap.
Block elements have 100% width by default. The height is as much as the element needs to contain its contents (which also applies to the
html elements). Change them whenever you think an element should have different width and height.
But I already set 0 for body which should already affect h1 though. Is there a reason why I need to specify for h1 again?
Setting the body’s margin to 0 does just that. It doesn’t affect anything else inside the body. You need to set the margin on the h1 itself