What is an HTML table?

An HTML table is used for the ​arrangement of data in rows and columns, or possibly in a more complex structure.

svg viewer

Defining tables in HTML

An HTML table is defined with the <table> tag. Following are some basic tags used for specifying the features of a table:

  • <tr> tag is used to define each row in a table.
  • <th> tag is used to define headers of a table.
  • <td> tag is used to define a table data or a cell.

By default, table headings are bold and centered while data is non-bold and left aligned.

Example:

Below is an example of defining a basic HTML table:

For easy reading of the table, line 4-8 are used to add borders to the headers and data cells.

  • HTML
Copyright ©2024 Educative, Inc. All rights reserved