-1

An element's padding is the space between its content and its border.

Consider the code below:

<p style="background-color: tomato; border: 1px solid black; padding:0px; ">A paragraph</p>

Here I am expecting no space between the text and the border because I am setting the padding to 0px, But I got the opposite result as shown in picture.

enter image description here

I am sure that, that space is not a padding, so why I am getting that space? Also is there any way to get rid of it?

Thanks)

Ninja
  • 59
  • 5

1 Answers1

0

Desktop browsers (including Firefox) use a default line-height 1.2 , depending on the element's font-family.

if you apply line-height = 1, then your problem solved ✅.

<p style="background-color: tomato; border: 1px solid black; padding:0px; line-height:1;">A paragraph</p>