Specifying the Width of a Column

Setting the overall table size is useful, but for more control, you might prefer to set the width of each column separately. To set the width of a column to a certain minimum amount, specify a width in the <td> tag for any cell within that column. You can use the same method you used for the <table> tag in the preceding section:

<td width="200px">

To specify the width of a column through a style sheet:

<td style="width: 200px">

The traditional place to set the column width is in the first row of the table, but that is not a requirement; you can set a width for any cell in any row. The column as a whole will be as wide as the widest cell in that column.

You can use either fixed amounts or percentages (of the table as ...

Get HTML and XHTML Step by Step now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.