Basically, I want to have an h1 and a p element on the same line, but the alignment is off a lot (meaning the H1 is higher than the P and looks crappy) and I've never had to do anything like this with css before!
I've thrown together a jsfiddle to accompany this, here is the code:
<h1 style="float:left;display:inline;">"Hi!</h1><p style="float:left;display:inline;">I'm James, and I <strong>LOVE</strong> building clean, fast and (most importantly) effective websites. Oh, and I also know a thing or two about computers.</p><h1 style="float:left;display:inline">"</h1>
http://jsfiddle.net/9H8xE/
Thanks!
One thing to remember, if you have different sizes of text that you need to align, is to align it to x-height or baseline. If there is a caps font then align them to baseline or cap-height. And remember NEVER to align horizontally different font sizes fonts on the central line.
Entire trick is to use float: left; CSS property on the img element and all the text will automatically wrap around that image. So if you want to align text and image in the same line in HTML like this... In short that is it.
That is, fonts at the same point size can have different x-heights and sometimes varying cap heights. This can be quite frustrating. Both the x-height as well as the cap height of a font affect its legibility, and will make different typefaces look larger or smaller at the same point size.
Some advice before answer:
http://jsfiddle.net/9H8xE/1/
Try this and let me know if it works
HTML:
<h1 >"Hi!</h1><p>I'm James, and I <strong>LOVE</strong> building clean, fast and (most importantly) effective websites. Oh, and I also know a thing or two about computers.</p><h1>"</h1>
CSS:
p
{
display:inline;
}
h1{
display:inline
}
The technical problem with the code in the question is that float: left
prevents display: inline
from taking effect, setting display
to block
instead, so remove all the float: left
declarations.
A different issue is that you have the closing quotation mark as the content of an h1
element after the p
element. This is very illogical. The technical implication is that this character will appear in the font size of h1
, causing uneven line spacing unless you set h1
font size to the same as p
font size. You need to decide what you want: why would you want to a have a large-size closing quote after normal-size text, and if you do, how should it be rendered?
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