html span: left and right align

Posted by – August 5, 2010

Refers to:
1. http://www.htmlcodetutorial.com/help/archive.php/o_t__t_3052__start_0__index.html
2. http://www.quackit.com/html/tags/html_span_tag.cfm

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:
Code:
<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>
</div>

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