HTML Usage::Table cell

::concepts

Table::cells    Style::border    Black::header    Colspan::''this    Rowspan::source    Tables::given

HTML Usage

Kinds of cell in HTML

A table cell in HTML is a non-empty element and should always be closed. There are two different kinds of table cell in HTML: normal table cell and header cell. <td> denotes a table cell, while <th> denotes a table header. The two can be used interchangeably, but it is recommended that header cell be only used for the top and side headers of a table.

Syntax

A table cell also must be nested within a <table> tag and a <tr> (table row) tag. If there are more table cell tags in any given row than in any other, the particular <tr> must be given a colspan attribute declaring how many columns of cells wide it should be.

Example

An example of an HTML table containing 4 cells:

Cell 1Cell 2
Cell 3Cell 4

HTML source: <source lang="html4strict">

     Cell 1
     Cell 2
     Cell 3
     Cell 4

</source>

Colspan and Rowspan

Every row must have the same number of table data cells, occasionally table data cells have to span more than one column or row. In this case the tags colspan and/or rowspan are used - where they are set to a nuack" width="5%"|
| border="none"|<-- This row has three table data cells |- |colspan="2" style="background:blue;"|
| style="background:black"|
| border="none"|<-- This row has two. The first uses colspan="2" |- |rowspan="2" style="background:maroon"|
| style="background:black"|
| style="background:black"|
|border="none"|<-- This row has three table data cells, but one spans two rows because it uses rowspan="2" |- | style="background:black"|
| style="background:black"|
|border="none"|<-- This row has only two table data cells, because its first is being taken up |}


Table cell sections
Intro  HTML Usage  See also  External links  

HTML Usage
PREVIOUS: IntroNEXT: See also
<<>>