Friday, December 20, 2024

HTML Table Headers

 In HTML, table headers are defined using the <th> element. These headers typically appear at the top of the columns in a table and are used to describe the content of the columns. Here’s an example of how to create a simple HTML table with headers:

<table border="1">
  <thead>
    <tr>
      <th>Header 1</th>
      <th>Header 2</th>
      <th>Header 3</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Row 1, Column 1</td>
      <td>Row 1, Column 2</td>
      <td>Row 1, Column 3</td>
    </tr>
    <tr>
      <td>Row 2, Column 1</td>
      <td>Row 2, Column 2</td>
      <td>Row 2, Column 3</td>
    </tr>
  </tbody>
</table>

Explanation:

  • <table>: Defines the table.
  • <thead>: Contains the header rows of the table.
  • <tr>: Represents a table row.
  • <th>: Defines a table header cell. Text inside <th> elements is usually bold and centered by default.
  • <tbody>: Contains the body of the table, where data rows are placed.
  • <td>: Defines a regular table cell.

This structure will produce a table with three columns, each having a header.

No comments:

Post a Comment

How can you refer to a CSS file in a web page?

 To refer to a CSS file in a web page, you use the <link> element inside the <head> section of the HTML document. Here's t...