HTML Element Style How to - Float button respectively on the left and right side of a 3-colspan table cell








Question

We would like to know how to float button respectively on the left and right side of a 3-colspan table cell.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#leftbutton {<!--from w  ww  .j  ava 2 s .  c  om-->
  float: left;
}

#rightbutton {
  float: right;
}
</style>
</head>
<body>
  <table>
    <tr>
      <td>short text</td>
      <td>long long long text</td>
      <td>short text</td>
    </tr>
    <tr>
      <td colspan='3'>
        <button id='leftbutton'>Left</button>
        <button id='rightbutton'>Right</button>
      </td>
    </tr>
  </table>
</body>
</html>

The code above is rendered as follows: