In this section, we will learn what HTML <table> element is and how to use it.
HTML to Create a Table: How to Make a HTML Table? (<table> Tag in HTML)
HTML <table> element is used to create a table in an HTML document.
This element is a container for the created table, but there are other important HTML elements that get involved creating parts of a table.
For example, HTML <tr> element is used to create a row in a table.
Or <th> and <td> elements are used to create the cells inside table rows.
So yeah, a <table> element is a container for other internal elements that create the actual table you see in an HTML document.
In short, these are the elements we use in the process of creating a table in HTML:
- HTML <thead> element: this is a container element and is used to group those rows in a table that belong to the header part of a table.
- HTML <tbody> element: this is a container element and is used to group those rows in a table that belongs to the main body of a table.
- HTML <tfoot> element: this is a container element and is used to group those rows in a table that belong to the footer part of a table.
- HTML <tr> element: this element is used to create rows in a table.
- HTML <th> element: this element is used to create table head cells.
- HTML <td> element: this element is used to create table data cells.
Note: all of these elements go in the body of an HTML <table> element.
HTML <table> Tag Syntax:
<table> </table>
Example: creating a table in HTML
See the Pen creating a table in HTML by Omid Dehghan (@odehghan) on CodePen.