Embedded padding/margin in fonts

后端 未结 16 1277
执念已碎
执念已碎 2021-01-08 00:56

It seems that all fonts have some sort of embedded padding or margin. By setting:

margin: 0px;
padding: 0px;

You never get what you want. D

16条回答
  •  误落风尘
    2021-01-08 01:34

    The native margins for text elements are as follows (at least in Firefox and Chrome):

    Working Example

     p{margin:16px 0;}
    h1{margin:21px 0;}
    h2{margin:19px 0;}
    h3{margin:18px 0;}
    h4{margin:21px 0;}
    h5{margin:22px 0;}
    h5{margin:24px 0;}
    

    To remove them you'll have to re-set the margin like so:

    p, h1, h2, h3, h4, h5, h6{margin:0;}
    

提交回复
热议问题