The <th> and <td> Tags
The
<th> (table header) and
<td> (table data) tags go inside the
<tr> tags of an HTML table to create the
cells and contents of each cell within a row. The two tags operate
similarly, except that header cells are typically rendered in bold
text and centered by default. <td> cell
contents are rendered in the regular base font, left-justified.
The align,
valign, and other attributes work the same in the
cell tags as they do in the row tag. When specified for
<th> and <td>,
these attributes override the same behavior set in the upper-level
tags for their specific cell.
The other attributes to the cell tags
are very important to the layout of your table. The
width attribute can set the width of a table cell
and all cells within its column. As with the
<table> tag, a value may be given in an
integer number of pixels or a percentage of the width of the table. A
width value may be ignored by the browser if
contents within the column have a fixed width larger than the value
(i.e., an image or nonbreaking line of text). You should use only one
width value in the cells of the same column. If
two width values are specified in the same column
of cells, the browser uses the larger value.
The
nowrap attribute, when included in a cell tag,
disables regular linebreaking of text within a table cell. With
nowrap, the browser assembles the contents of a
cell onto a single line, unless you insert a
<br> or <p> tag,
which forces a break.
Cell Spanning
It is common ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access