Use a CSS Reset

CSS resets help enforce style consistency across different browsers with a clean slate for styling elements. You can use a CSS reset library like Normalize, et al., or you can use a more simplified reset approach:

  1. *,
  2. *::before,
  3. *::after {
  4. box-sizing: border-box;
  5. margin: 0;
  6. padding: 0;
  7. }

Now elements will be stripped of margins and padding, and box-sizing lets you manage layouts with the CSS box model.

Demo

Note: If you follow the Inherit box-sizing tip below you might opt to not include the box-sizing property in your CSS reset.