What is the thead element in HTML?

The <thead> element in HTML is used to wrap the header content of an HTML table to specify the header part of the table. <thead> is used alongside the <tbody> and <tfoot> elements to structure the HTML table content into its header, body, and footer parts.

Usage

  • The <thead> element must be a child of the <table> element.
  • <thead> must contain at least one <tr> element.
  • <thead> must come before any <tbody>,<tr>, and <tfoot> elements.
  • <thead> does not affect the layout of the table.
  • <thead> can be styled using CSS.

Example

Explanation

In the above HTML code, we display an HTML table that is structured into header, body, and footer content. The header content, which is the row containing “Subject” and “Marks,” is wrapped inside the <thead> element.

Copyright ©2024 Educative, Inc. All rights reserved