Techoceanhub logo

Table headers and cells in HTML

In HTML, tables are created using the <table> element, and you can define table headers using the <th> (table header) element and table cells using the <td> (table data/cell) element. Here’s an example of how to structure a basic table with headers and cells:

<table>
  <tr> <!-- Table row -->
    <th>Header 1</th> <!-- Table header cell -->
    <th>Header 2</th>
    <th>Header 3</th>
  </tr>
  <tr>
    <td>Cell 1</td> <!-- Table data cell -->
    <td>Cell 2</td>
    <td>Cell 3</td>
  </tr>
  <tr>
    <td>Cell 4</td>
    <td>Cell 5</td>
    <td>Cell 6</td>
  </tr>
</table>

In this example, we have a table with three columns (Header 1, Header 2, Header 3) and two rows. The first row contains the table headers (<th>) and the subsequent rows contain the table cells (<td>).

You can add more rows by adding additional <tr> elements, and within each row, you can include more header cells (<th>) or data cells (<td>), as needed.

It’s worth mentioning that tables are typically used for tabular data, so make sure to use them appropriately according to the content you want to display.


Share:

Categories

Archives

Related Posts

Array Destructuring

Array Destructuring Array destructuring is a powerful syntax introduced in ES6 that allows you to unpack elements from an array

Read More »

Explore our Affiliated partner links

hostgator website plan

Hostgator

Best Website hosting plans & Best for 24/7 support.

hostinger webhosting plan

Hostinger

Reasonable website hosting packages for small business & 24/7 Email support

Elementor pro

Design Worpdress website quickly using Elementor Builder and AI

buy elementor website templates

Buy Elementor Website Template

Buy ready made Elementor Website Template from us & Get Free Elementor pro licence for 1 year .