DEV Community

Cover image for HTML tags | table
Carlos Espada
Carlos Espada

Posted on • Updated on

HTML tags | table

It is used to represent tabular data, that is, information presented in a two-dimensional table made up of rows and columns of cells that contain data.

It currently has no attributes, other than global ones, since they are all deprecated.

The elements it can contain are, in this order:

  1. An optional <caption> element
  2. Zero or more <colgroup> elements
  3. An optional <thead> element
  4. Any of the following:
    • Zero or more <tbody> elements
    • One or more <tr> elements
  5. An optional <tfoot> element

Has an implicit ARIA role table

Providing a <caption> element clearly and briefly describing the purpose of the table helps users of some assistive technologies decide whether to read the rest of the content of the table or skip it. It is important to make good use of the scope attribute in the <th> so that the table is readable for these same users.

There are times when certain assistive technologies may have trouble parsing and interpreting tables if they are too complex, especially when using colspan and rowspan. In those cases it is usually better to try to separate that table into a set of smaller related tables so that these attributes do not have to be used. That will benefit not only users of assistive technologies, but people with cognitive problems. If it cannot be separated, a combination of id and headers will have to be used to associate each data cell with its corresponding header cell.

  • Type: table
  • Self-closing: No
  • Semantic value: No

Definition | Example | Support

Discussion (0)