Search code examples
csshtml-tablealignment

How to align text in a table cell?


<table>
   <tr>
      <td>
         <input type="checkbox" id="41" value="1">   
         Don't overwhelm yourself
         <span style="color:black;float:right">111111</span>
      </td>
   </tr>
</table>

The text 111111 doesn't go to the right.

When I use align:right, it is the same.

<table>
   <tr>
      <td>
         <input type="checkbox" id="41" value="1">   
         Don't overwhelm yourself
         <span style="color:black;align:right">111111</span>
      </td>
   </tr>
</table>

How to solve this problem?


Solution

  • <!-- width 100%, so we can see the floating -->
    <table style="width:100%">
      <tr>
        <!-- width 100%, so we can see the floating -->
        <td style="width:100%" >
    
          <!-- float to left -->
          <input style="float:left" type="checkbox" id="41" value="1">    
          <span style="float:left"> Don't overwhelm yourself </span> 
    
          <!-- float to right -->
          <span style="color:black;float:right">111111</span> 
    
          <!-- clear floating -->
          <br style="clear:both" /> 
        </td>
      </tr>
    </table>
    

    check sample here