HTML Tables Tutorial

Page 15 - <td> width


Along with being able to specify a table's width, the width of a cell, or column, can be controlled by using the attribute width in the <td> tag. It tends to be very important to specify the width of every cell in a table. Although sometimes you can just specify the first row in a table, it is better to be safe than sorry and specifically control every <td>. By specifing widths, you can contain text and cause it to wrap.


<table border="1" width="300">
   <tr>
      <td>Cell #1</td>
      <td>Cell #2</td>
   </tr>
   <tr>
      <td>Cell #3</td>
      <td>Cell #4</td>
   </tr>
</table>
=
Cell #1 Cell #2
Cell #3 Cell #4

<table border="1" width="300">
   <tr>
      <td width="260">Cell #1</td>
      <td width="40">Cell #2</td>
   </tr>
   <tr>
      <td width="260">Cell #3</td>
      <td width="40">Cell #4</td>
   </tr>
</table>
=
Cell #1 Cell #2
Cell #3 Cell #4
 
 
MPF.com Site Map