html span: left and right align

Posted by – August 5, 2010

Refers to:

Here’s a solution that might work for you (did for me)

I have multiple lines each enclosed in <div> tags. I want to have some left adjusted and right adjusted text on each line.

Here is some code for one line:
<div name=”line”>
<div name=”left_text” style=”text-align: left”>My left text</div>
<span name=”right_text” style=”float: right”>My right text</span>

As I understand it, the (inside) div is a block level element so it can be left adjusted. The span is a line level element, so it cant’ be right adjusted, but it can be floated on the right (just like an image would).

Leave a Reply