| Viewed 204 times

How to create a table in HTML


How to create a table in HTML

1 Answer
Mikdam Qandeel
Answered
2

First of all, you have to Define an HTML Table

and we define it with the <table> tag.

Then, we know that any table consists of columns and rows, But HTML table is always based on rows, never columns.
so the row is defined with the <tr> tag.

A table header is defined with the <th> tag. And by default, the table headings are bold and centered.

A table data/cell is defined with the <td> tag.

Example:

<table style="width:100%">
  <tr>
    <th>Country</th>
    <th>Capital</th> 
    <th>continent</th>
  </tr>
  <tr>
    <td>Jordan</td>
    <td>Amman</td> 
    <td>Asia</td>
  </tr>
  <tr>
    <td>Palestine</td>
    <td>Al-Quds</td> 
    <td>Asia</td>
  </tr>
</table>

Output:

Country Capital continent
Jordan Amman Asia
Palestine Al-Quds Asia