How to align the <span> text at top of the <div> if float:right is applied to the <span>.
Here is my code:
span {
float: right;
}
<div>Lorem ipsum dolor sit amet,
<br>consectetuer adipiscing elit,
<br> sed diam nonummy nibh dolore
<span>Align me</span>
</div>
I tried vertical-align:text-top but its not working.
I can't use negative margin and can't even make any changes to HTML.
Please see this and let me know.
span {
float: right;
position: relative;
bottom:40px;
}
You can align it to the top right using position: absolute:
p {
position: relative;
}
span {
position: absolute;
top: 0;
right: 0;
}
<p>Lorem ipsum dolor sit amet, <br>consectetuer adipiscing elit,<br> sed diam nonummy nibh dolore <span>Align me</span></p>
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