Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

-webkit-margin adds unwanted margin on texts

Tags:

css

padding

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?

like image 290
tbleckert Avatar asked Apr 19 '11 20:04

tbleckert


People also ask

Does text have margin?

No, plain text has no default margin. Besides, if there were a margin, it would appear outside the border; the spacing between content and border is padding.

How do I give a text margin?

Margins on text is controlled by STYLE="margin: ", which is a style that can be used on all types of text section, including the BODY tag. Written like this, you specify all four margins in one take.


1 Answers

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!

like image 90
JacobEvelyn Avatar answered Sep 28 '22 18:09

JacobEvelyn