ymd_ ymd_ - 19 days ago 7
CSS Question

Why <p> have two line breaks instead one?

I donĀ“t understand why

<p>
tag in HTML has two line breaks instead one, can someone tell me why its like that and if its possible to fix it to one with CSS.

Two line breaks:



<p>Hello World</p>my name is Yoel.





Compares with
<br>
one line break:



Hello World
<br>my name is Yoel.




Answer

What you're seeing isn't actually an extra line-break, but a margin. By default p tags come with a small margin to help visually define them.

If you want to get rid of that you can add the following to your CSS:

p {
    margin: 0;
}