I’ve been trying to remove the default new line after the first p but without any success.
The second p should be underneath the first one, but not on the same line.
span {
float: left;
clear: left;
}
<div id="product-info">
<p><b>Test Test</b></p>
<p>Product Information:</p>
<span>A: Test</span>
<span>B: Test</span>
<span>C: Test</span>
</div>
Can someone suggests some hints?
3
Answers
Use a single
<p>
tag, and use a line break<br />
The natural margin of
<p>
margin-bottom (below the element) of the tag is1em
. You can also remove that margin if you addBut if you like the margin, and just want the space between to two lines gone .. Just use line break.
As a side note ..
<span>
is designed to be inline. So something likewould be an example of how it’s meant to be used. For stacked elements, use the
<div>
tag instead, as it’s display is naturallyblock
and will stack naturally without the need for additional CSS rules:It’s not a newline. It’s margin. Use your browser’s document inspector to see this. it looks like this in Chrome:
Create custom classes to remove the margins below the first and above the second paragraph.
Then, if you want block-level elements, use block-level elements. Floats aren’t a good layout strategy in the 21st century.
Remove the
margin
.