Reputation: 11888
I do have the following code:
<div>
<span class='foo' style='font-size: 10px'>Foo</span>
<span class='blah' style='font-size: 25px'>Blah</span>
</div>
I would like to top align both of them. At the minute, Foo is not top aligned because the font-size of Blah is bigger. How can I fix this ?
Here is a codepen
Upvotes: 0
Views: 172
Reputation: 3430
You can achieve this using
span {
vertical-align: top;
}
As you can see using the green background both divs are aligned using their top corner. If you want to do further aligning you can although add display: inline-block
, to stylize them and add paddings:
span {
vertical-align: top;
display: inline-block;
}
span.foo {
margin-top: 3px;
}
This time they look like their top is aligned (even if the first one is actually below the second one).
Upvotes: 1