user6771987 user6771987 - 2 months ago 5
CSS Question

How to make span appear on each end of a TD



<table width="200pxpx" bgcolor="#00FF00">
<tr>
<td>
<span align="left">1</span>
<span align="right">2</span>
</td>
</tr>
</table>





What I would like to achieve is that 1 appears at the left end and 2 appears at the other end.

So in the script, 1 and 2 both show up at the left end of the TD.

I've also tried to add "align" attribute to make it happen but it didn't work either.

Answer

What you're looking for is the css-style float:right.

<table style="width:200px; background-color:#00FF00;">
  <tr>
    <td>
      <span style="float:left;">1</span>
      <span style="float:right;">2</span>
    </td>
  </tr>
</table>

Edit: It's also better to use style for the other styling of your table (this is HTML5 standard I believe)