Is it possible in pure css, that is without adding additional html tags, to make a line break like <br>
? I want the line break after the <h4>
element, but not before:
HTML
<li>
Text, text, text, text, text. <h4>Sub header</h4>
Text, text, text, text, text.
</li>
CSS
h4 {
display: inline;
}
I have found many questions like this, but always with answers like "use display: block;", which I can't do, when the <h4>
must stay on the same line.
You can use ::after
to create a 0px
-height block after the <h4>
, which effectively moves anything after the <h4>
to the next line:
h4 {_x000D_
display: inline;_x000D_
}_x000D_
h4::after {_x000D_
content: "";_x000D_
display: block;_x000D_
}
_x000D_
<ul>_x000D_
<li>_x000D_
Text, text, text, text, text. <h4>Sub header</h4>_x000D_
Text, text, text, text, text._x000D_
</li>_x000D_
</ul>
_x000D_
Source: Stackoverflow.com