HTML Tables Tags Example


The <table> tag is very important for HTML. This tag has some attributes like border, width, and height.

The <tr> tag defined to a table row. It must write inside the <table> tag. A table can have more than one row.

The <th> tag defined to a table header. It must write inside the <tr> tag.

The <td> tag defined to a table data cell. It must be written inside the <tr> tag.

Tag Name Description
<table> Defines a table Element
<tr> Defines a table row
<td> Defines a table cell or table data
<th> Defines a table header cell
<caption> Defines a table caption
<colgroup> Defines a group of columns in a table, for formatting
<col> Defines attribute values for one or more columns in a table
<thead> Groups the header content in a table
<tbody> Groups the body content in a table
<tfoot> Groups the footer content in a table
Example
<table style="width:100%">
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>John</td>
    <td>Doe</td>
    <td>35</td>
  </tr>
  <tr>
    <td>Smith</td>
    <td>mikel</td>
    <td>40</td>
  </tr>
</table>