Which HTML tag is used to create a table row?

Understanding the HTML Table Row Tag

The HTML <tr> tag is used to create a table row. The term 'tr' stands for 'table row'. This tag must be included within a <table> element or an element that can act as its parent. Each <tr> tag designates a single row in the table that can hold one or more cells. It's inside these cells where the table data or headers are placed.

Typically, a table constructed in HTML would follow this basic structure:

<table>
    <tr>
        <td>Data</td>
        <td>More Data</td>
    </tr>
    <tr>
        <td>Further Data</td>
        <td>Even More Data</td>
    </tr>
</table>

Each <td> tag here, short for 'table data', represents a single cell within the row. As you can see in the example, each row can have multiple cells containing different sets of data.

It's also worth noting another closely related tag, <th>. The <th> tag is used to create a table header cell. These are similar to <td> tags but are typically used to provide titles for columns or rows:

<table>
    <tr>
        <th>Header</th>
        <th>Another Header</th>
    </tr>
    <tr>
        <td>Data</td>
        <td>More Data</td>
    </tr>
</table>

In the example above, you can see that the <th> tags are used in the first row to indicate the type of data presented in the columns below.

When creating tables in HTML, it's best practice to use <tr>, <td>, and <th> to clearly delineate your table structure. Explicitly marking out your rows and clearly defining whether each cell contains data or headers will make your tables much easier to read, both for users and for any software interpreting the mark-up, such as search engine crawlers.

Do you find this helpful?