Reputation: 894
I think this padding is always added to all elements, but it is inconvenient for vertical margin calculation because of this padding. I want to get rid of this padding. What should I do?
div { background-color:DodgerBlue; }
<div>ABCDE</div>
Upvotes: 2
Views: 269
Reputation: 7266
You are getting the spacing on top and bottom of the text as your text is smaller than the containing container. Its actually not a padding (At least padding in terms of CSS).
You could either increase the line height of the text so that the text occupies more space and fits the container, or you could increase the font size to achieve the same.
div {
background-color:DodgerBlue;
line-height: 12px;
}
<div>ABCDE</div>
Upvotes: 1