-webkit-margin adds unwanted margin on texts

tbleckert picture tbleckert · Apr 19, 2011 · Viewed 93.1k times · Source

This hadn't hit me until now (and this is not only in webkit browsers). On all texts in like p tags, h1 tags etc... there's an extra space over and below the text.

In chrome I found this:

user agent stylesheet

-webkit-margin-before: 1em;
-webkit-margin-after: 1em;
-webkit-margin-start: 0px;
-webkit-margin-end: 0px;

This makes the alignment wrong in some places. And yes I'm using a reset stylesheet and no padding or margin are added. Pretty much a basic setup. Why is this and how do I solve it?

Answer

JacobEvelyn picture JacobEvelyn · Mar 7, 2012

You can also directly modify those attributes like so:

-webkit-margin-before:0em;
-webkit-margin-after:0em;

Works for me in Chrome/Safari. Hope that helps!