Here is a simple example for you to observe the issue (also useful for debugging HTML/CSS). The <p>
and <div>
elements are by default considered as block level
.
https://i.sstatic.net/2GWiE.png
I highly recommend spending 3 minutes to go through the following link:
REF:
p.train {
margin: 0;
font-size: 2.5vw;
background: red;
}
<div>
<p class="train">In Training</p>
<hr>
</div>
Solution:
To resolve this, set the p
element to inline-block.
or
You can also use a span
, which is an inline element:
p.train {
margin: 0;
font-size: 2.5vw;
background: red;
display: inline-block;
}
.green {
margin: 0;
font-size: 2.5vw;
background: red;
}
<div>
<p class="train">In Training</p>
<hr>
<span class="green">In Training</span>
</div>