How Do I get rid of the white margins?

I followed a tutorial by TraversyMedia and was wondering how I can take the white margins at the top and sides off.

I would give your html, body

  margin:-10px 0 0 0;
  padding: 0;

Looks like it has to do with paddings and margins of your html and body.

I tried margin: -10px 0 0 0; on mine and had some trouble with mobile responsiveness. I ended up forgoing it and accepting the white margin. But if I could do it again, I might do the tried and true:

(star)* {
margin: 0;
padding: 0;
}

I wrote star parenthetically to avoid the auto-bullet-point. Let me know if this works. Or if @shimphillip’s solution worked; I am genuinely curious whether the margin-top: -10px works for others in codepen.

You dont need to give the negative margin of 10px on body. Its the <h2> tag which has a margin of 0.83em vertically. so if you set the margin of <h2> to 0, it will remove the white space on top. Also, dont forget to give your body a margin of 0px.

1 Like