Search code examples
htmlcssmarginpadding

How do i remove the padding/margin of my html file?


I tried to make my picture go to the edge, i tryed setting margin/padding to 0 in classes, but I kept having this little leftover margin:

picture of the wired margin

I read that I should manually reset margin and padding because some browsers come with a default padding if none is specified but it hasn't worked. Right now my CSS code looks like this:

.navpicture {
  margin-top: 0%;
  margin-right: 0%;
  margin-left: 0%;
  margin-bottom: 0%;
  padding: 0%;
  background-color: white;

}

Solution

  • You have to "reset" (i.e. set to 0) the margin of the body element, not that of your own div. So you should add this rule to your CSS:

    html, body {
      margin: 0;
    }