Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags


How to use the 'table' element in HTML

Dian Us Suqlain

Table is one of the elements in HTML that we can use to create tables in our web pages.

The table element

An HTML table element consists of some tags and attributes necessary to build a table. Those tags are as follows:

  • <td>: defines a standard data cell in an HTML table.
  • <tr>: defines a row in an HTML table.
  • <th>: defines a header cell in an HTML table.
The <table>, <tr>, <th> and <td> tags.


As shown in the illustration above, a <table> tag uses multiple elements to create a simple table in HTML. The following syntax shows how to create a table with three rows and one element in each row.



Consider the following example code that demonstrates how to create a table in HTML.


In the implementation above, we have made three data entries using the <td> (John, Jessica, and Billy), along with their respective ages.

The <th> tag creates headings for Name and Age. Both the <th> and <td> tags are included inside the <tr> tag to group them in a single row.

We use CSSCascade Style Sheets to make a border around the table entries so that it will look like an actual table.




Dian Us Suqlain
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring