Line break when using CSS "display: inline"
I managed to get <p>by following <h>on the same line, however I want to repeat this on a new line, but the next <h>follows the last <p>- what should I do?
I tried various “clear” options, but none broke the line. I really do not want to use <br>or have an empty <p>, not too happy to surround with <div>.
Note. I tried removing inlinefrom the second element <h>, and while it is putting <h>in a new line, the next one <p>ends on its own line.
CSS
.inline {display: inline;}
.newline {clear: left;}
HTML
<h5 class="inline">Heading:</h5>
<p class="inline">Some text.</p>
<h5 class="inline newline">Next Heading:</h5>
<p class="inline">Some more text.</p>
This is the result I want to achieve:
Title ..
.
:
: . .
- .
[]
div, hafid2com, ( ):
.clear { clear: both; display: block; content: ""; width: 100%; }
<div class="clear"></div>
:
1) float, display:
<style type="text/css">
h5 {float:left;clear:left;}
p {float:left;}
</style>
<h5>Heading:</h5>
<p>Some text.</p>
<h5>Next Heading:</h5>
<p>Some more text.</p>
2) <h5> <strong> <p> ( @Ralph.m , <h5> <p> ):
<p><strong>Heading:</strong> Some text.</p>
<p><strong>Next Heading:</strong> Some more text.</p>
3) display:inline; <h5> <p> <div>:
<style type="text/css">
h5, p {display:inline;}
</style>
<div>
<h5>Heading:</h5>
<p>Some text.</p>
</div>
<div>
<h5>Next Heading:</h5>
<p>Some more text.</p>
</div>
, , :before . \A, \00000a, ISO-10646 (U + 000A).
http://jsfiddle.net/TwoD/ujhwLouc/
CSS
.inline {display: inline;}
h5.inline.newline:before {content: '\A'; white-space:pre-line;}
HTML
<h5 class="inline">Heading:</h5>
<p class="inline">Some text.</p>
<h5 class="inline newline">Next Heading:</h5>
<p class="inline">Some more text.</p>