HTML Tables



index
Disabled back button Next Section
printable version

Section 1: Overview

The table element provides a markup-based structure for tabular data.

Table components.
Section 2: Basic Tables

Tables are defined with the <table> tag.

Section 3: Table Headers

You can also specify table headers using a <th> tag.

Section 4: Spanning Multiple Columns and Rows (reference only)

colspan

The colspan attribute accepts a positive integer and instructs the browser to create a cell that spans as many columns of the table as the attribute's value indicates.

rowspan

The rowspan attribute accepts a positive integer and instructs the browser to create a cell that spans as many rows of the table as the attribute's value indicates.

Section 5: Scope (reference only)

The scope attribute provides information about the context of a table header, particularly for users with disabilities.

Section 6: Grouping Table Elements (Reference Only)

We'll turn our attention to a collection of elements whose job is to increase the semantic value of your data tables.

Using these grouping elements will result in a more accessible data table.

Each of the first three row group elements – thead, tbody, and tfoot – must appear as direct children of their parent table element.

Table Heading Row Group

The thead element, also known as a table heading row group, contains the row or rows that act as column headings for its parent table element.

Table Row Group

The tbody element, also known as a table row group, represents one or more rows that make up the body of data of its parent table element.

Table Footer Row Group

The optional tfoot element, known as a table footer row group, represents a row or rows whose content consists of the column summaries for its parent table element.

Column Group

The colgroup element represents a logical grouping of one or more columns in a table.

Section 7: Caption

The <caption> tag defines a table caption.



Positioning Recap

The elements within a table element must appear in this prescribed order:

Section 8: Empty Cells

Note that you can create an empty cell using a non-breaking space (&nbsp;).

Section 9: Repeat Warning

Remember: HTML tables should never be used to define the layout of HTML pages, but only to store table data in a table.

Section 10: Let's Play

Click the "Edit and Click Me >>" to see the results of the html code in the left panel in the panel on the right.

Then, play around with the html code, making changes and seeing the effect of those changes in the right panel.

Section 11: Resources