I'm trying to place some text inside the P tag after the closing H1 tag like this:
Headline And here are the text right after....
But I can't get it to work. I made this CSS, but something is perhaps missing?
CSS:
p.start { font-family: 'Open Sans', sans-serif; font-size: 16px; line-height: 28px; text-align: justify; display: inline; } h1.start { font-family: 'Open Sans', sans-serif; font-size: 16px; line-height: 28px; margin: 0; display: inline-block; }
HTML:
<div id="containerIntro"> <h1 class="start">Headline </h1> <p class="start">Text......</p> </div>
The header tags are block-level elements, and cannot go inside <p> tags even when you style them to display inline.
To display multiple div tags in the same line, we can use the float property in CSS styles. The float property takes left, right,none(default value) and inherit as values. The value left indicates the div tag will be made to float on the left and right to float the div tag to the right.
Just make your <h1> display:inline. This way, it will render in the normal text flow.
So if you had:
<div id="containerIntro"> <h1>Headline</h1> <p>And here the text right after...</p> </div>
Your CSS would have to look something like this:
#containerIntro h1, #containerIntro p { display: inline; vertical-align: top; font-family: 'Open Sans', sans-serif; font-size: 16px; line-height: 28px; }
See http://jsfiddle.net/F3Bcd/3/.
Both <p>
and <h1>
elements are block level - that means they take up the complete width of their container. You can try floating both elements to the left. This stacks them up on each other to the left side and also converts them to inline elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With