I need to display two lines of text with different font size, one after another, so that their top lines were at the same vertical position, i.e.:
I tried to use vertical-align: top
, but no luck. Instead of expected result I have this:
Is there some standard way to achieve the desired result?
Here is my HTML:
<div id="container">
<span>TEXT</span> TEXT
</div>
and CSS:
#container {
font-size: 30px;
}
#container span {
font-size: 16px;
vertical-align: top;
}
Use a <span> with float: left for the left word, and another <span> with float: right for the right word. There are other alignment techniques as well, but I don't think it's possible without separating the words into their own elements. Show activity on this post.
One way would be:
#container span {
position: relative;
top: 2px;
}
Adjust the 2px to suit.
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