I cannot get the text inside my <header>
to align to a baseline grid when the text wraps.
HTML:
<header>
<h1>Sample Title</h1>
<p class="tag">#Tag</p>
</header>
CSS:
header {
display: block;
}
h1 {
display: inline;
font-size: 36px;
line-height: 36px;
margin: 0 24px 0 0;
}
p {
display: inline-block;
font-size: 18px;
line-height: 36px;
margin: 0 24px 0 0;
}
[Good] Text without wrapping
[Bad] Text does not align to grid when it wraps between <h1>
and <p>
[Good] Text aligns to grid when it wraps through <h1>
I followed @sled's suggestion to set line-height: 0
on <header>
, but that gave me the opposite problem:
[Good] Text aligns to grid when it wraps between <h1>
and <p>
[Bad] Text does not align to grid when it wraps through <h1>
`. When `
` wraps, Firefox calculates `
`'s height as 77px instead of 72px.
` and `
` elements. Unfortunately, floating `
` and `
` pushes `
` to a new line when `
` wraps.
– Brandon Lebedev May 22 '13 at 18:20