Search code examples
htmlcssstylesheet

Add additional 8px to margin


I have 2 div, one is using position :absolute and another is using position : static (default)
the absolute position by left : 100px.
the static position by margin-left : 100px

Why they aren't the positions at same place?

where is the 8px?


Solution

  • Posting a link to the fiddle would be nice, but until then you could try setting:

    html, body
    {
      margin: 0;
      padding: 0;
    }
    

    Since the absolutely positioned div has been taken out of the normal flow of the document, it is most likely that any inconsistencies between the placement of the static div and the absolute div are caused by margin's or padding's set on the elements containing the static div.