How can I align text so that some of it aligns to the left and some of it aligns to the right within the same line?
This text should be left-aligned
While several of the solutions here will work, none handle overlap well and end up moving one item to below the other. If you are trying to layout data that will be dynamically bound you won't know until runtime that it looks bad.
What I like to do is simply create a single row table and apply the right float on the second cell. No need to apply a left-align on the first, that happens by default. This handles overlap perfectly by word-wrapping.
HTML
<table style="width: 100%;">
<tr><td>Left aligned stuff</td>
<td class="alignRight">Right aligned stuff</td></tr>
</table>
CSS
.alignRight {
float: right;
}
https://jsfiddle.net/esoyke/7wddxks5/
HTML:
<span class="right">Right aligned</span><span class="left">Left aligned</span>
css:
.right{
float:right;
}
.left{
float:left;
}
Demo:
http://jsfiddle.net/W3Pxv/1
<p style="text-align:left;">
This text is left aligned
<span style="float:right;">
This text is right aligned
</span>
</p>
https://jsfiddle.net/gionaf/5z3ec48r/