HTML Table

HTML Tutorial

HTML Forms

HTML Graphics

HTML Media

HTML API

Html Tables

Define an HTML Table

A table in HTML has table cells within rows and columns.

Example

				
					<!DOCTYPE html>
<html>
<body>
<h2>A basic HTML table</h2>
<table style="width:100%">
  <tr>
    <th>Company</th>
    <th>Contact</th>
    <th>Country</th>
  </tr>
  <tr>
    <td>Alfreds Futterkiste</td>
    <td>Maria Anders</td>
    <td>Germany</td>
  </tr>
  <tr>
    <td>Centro comercial Moctezuma</td>
    <td>Francisco Chang</td>
    <td>Mexico</td>
  </tr>
</table>
<p>To understand the example better, we have added borders to the table.</p>
</body>
</html>

				
			

Output:

A basic HTML table

Company Contact Country
Alfreds Futterkiste Maria Anders Germany
Centro comercial Moctezuma Francisco Chang Mexico

To understand the example better, we have added borders to the table.

Table Cells

A table in HTML has table cells within rows and columns.

Each table cell is illustrated by a <td> and a </td> tag.

td denotes table data.

Everything within <td> and </td> is the content of the table cell.

Table Rows

Each table row is startes with a <tr> and end with a </tr> tag.

tr denotes table row.

Table Headers

Using the <th> tag instead of the <td> tag allows you to make cells to be headers