HTML Tables
Tables are defined with the tag.
A table is divided into rows (with the
tag), and each row is divided into data cells (with the tag). td stands for "table data," and holds the content of a data cell. A tag can contain text, links, images, lists, forms, other tables, etc.
Table Example
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
How the HTML code above looks in a browser:
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
HTML Tables and the Border Attribute
If you do not specify a border attribute, the table will be displayed without borders. Sometimes this can be useful, but most of the time, we want the borders to show.
To display a table with borders, specify the border attribute:
Row 1, cell 1 | Row 1, cell 2 |
HTML Table Headers
Header information in a table are defined with the tag.
All major browsers display the text in the element as bold and centered.
Header 1 | Header 2 |
---|---|
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |
How the HTML code above looks in your browser:
Header 1 | Header 2 |
---|---|
row 1, cell 1 | row 1, cell 2 |
row 2, cell 1 | row 2, cell 2 |