HTML tables can have headers for each column or row, or for many columns/rows.
EMIL | TOBIAS | LINUS |
---|
8:00 |
---|
9:00 |
10:00 |
11:00 |
12:00 |
13:00 |
MON | TUE | WED | THU | FRI |
---|---|---|---|---|
8:00 | ||||
9:00 | ||||
10:00 | ||||
11:00 | ||||
12:00 |
Table headers are defined with th elements. Each th element represents a table cell.
Firstname | Lastname | Age |
---|---|---|
Jill | Smith | 50 |
Eve | Jackson | 94 |
To use the first column as table headers, define the first cell in each row as a element:
Firstname | Jill | Eve |
---|---|---|
Lastname | Smith | Jackson |
Age | 94 | 50 |
By default, table headers are bold and centered:
Firstname | Lastname | Age |
---|---|---|
Jill | Smith | 50 |
Eve | Jackson | 94 |
To left-align the table headers, use the CSS text-align property:
You can have a header that spans over two or more columns.
Name | Age | |
---|---|---|
Jill | Smith | 50 |
Eve | Jackson | 94 |
To do this, use the colspan attribute on the element:
Name | Age | |
---|---|---|
Jill | Smith | 50 |
Eve | Jackson | 94 |
You will learn more about colspan and rowspan in the Table colspan & rowspan chapter.
You can add a caption that serves as a heading for the entire table.
Month | Savings |
---|---|
January | $100 |
February | $50 |
To add a caption to a table, use the tag:
Month | Savings |
---|---|
January | $100 |
February | $50 |
If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
sales@w3schools.com
If you want to report an error, or if you want to make a suggestion, send us an e-mail:
help@w3schools.com
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookie and privacy policy.