How to align one word left and another word right within the same div?
The text-align-last property specifies how to align the last line of a text. Notice that the text-align-last property sets the alignment for all last lines within the selected element. So, if you have a <div> with three paragraphs in it, text-align-last will apply to the last line of EACH of the paragraphs.
To get all elements to appear on one line the easiest way is to: Set white-space property to nowrap on a parent element; Have display: inline-block set on all child elements.
<div>
<div class="left">left text</div>
<div class="right">right text</div>
</div>
.left {
float: left;
}
.right {
float: right;
}
<div>
<div class="left">left text</div><!-- no space here
--><div class="right">right text</div>
</div>
.left {
text-align: left;
}
.right {
text-align: right;
}
.left, .right {
display: inline-block;
width: 50%;
}
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