Muleskinner
Muleskinner

Reputation: 14458

html tables, whats the purpose of th

What is the reason were having the th (X)HTML tag. My thought is that th is redundant as it goes under thead and td should be sufficient.

And if there is a good reason for having th, as there probably is, why does not exist a tf tag to be placed under tfoot?

Upvotes: 2

Views: 548

Answers (3)

rahool
rahool

Reputation: 639

Cells in a table may contain two types of information: header information and data.

The TH element defines a cell that contains header information.
The TD element defines a cell that contains data.

This difference enables browsers to render header and data cells distinctly, even in the absence of style sheets. For example, some browsers may present header cell text with a bold font.

Upvotes: 1

Amadan
Amadan

Reputation: 198294

thead was introduced in HTML 4.0, th was older than that (see HTML 3.2 spec) - so th was the only available mechanism for distinguishing the headers from the regular cells. Also, you can use th as row headers as well, for instance.

Upvotes: 1

Quentin
Quentin

Reputation: 943089

It is possible to have table heading cells that are not part of a table header. Examples include a column of headings and headings that apply to only a section of a (complex) table (the sort where the td elements would need to make use of the headers attribute).

Headings are not data so a table data cell would not be appropriate. Footers are for data such as totals, which are still data so <td> would be suitable for them.

Upvotes: 3

Related Questions