Search code examples
htmlhtml-table

html tables: thead vs th


It looks like (according to the examples on this page, anyways) that if you're using THEAD, you don't need to use TH.

Is that true? If so, what are the advantages/disadvantages of THEAD vs TH?


Solution

  • The <thead> tag is used to group the header content in an HTML table. The thead element should be used in conjunction with the tbody and tfoot elements.

    More: thead

    Using the words of Marc Seyon:

    You use <thead> to encapsulate an entire row (or rows) to designate them as the Table Header.

    [...]

    According to the spec, "This division enables user agents to support scrolling of table bodies independently of the table head and foot. When long tables are printed, the table head and foot information may be repeated on each page that contains table data."

    http://www.w3.org/TR/html4/struct/tables.html#h-11.2.3

    <th>, on the other hand, is used to style a specific cell as a header cell rather than an ordinary data cell.