search

THead Tag in HTML

Sep 04, 2024 pm 04:30 PM
htmlhtml5HTML TutorialHTML PropertiesHTML tags

The element or tag is used in hand with

tag and tag, defining the table header, table footer, and table body, respectively. The elements define the header of an HTML table. To define a row or set of rows that create the column heads of a table, we use the element. In other words, this element groups the header content in an HTML table. It encloses an entire row or rows and classifies it as Table Header. In this topic, we will learn about THead Tag in HTML.

A Table Header consists of a row or rows containing information about the columns or table body data.

How to use Element in HTML?

The element specifies the header part of the HTML Table. This thus secures a position as the immediate child of a table element,

. Before using any, , or element. The element may appear after any element if any, and element will contain at least one row of data enclosed in element.

Syntax

<thead>
<tr>
</tr>
</thead>

Of course, as shown above, just like any other HTML element,

element too works in pairs, opening tag, has a partner, a closing tag, .

Examples of THead Tag in HTML

Consider the following example:

Example #1

Code:


<title>HTML thead Tag</title>

elements, use the
element. The
This is the header section of the table
This is the footer section of the table
Data 1 Data 2 Data 3 Data 4
...more rows of data here...
...
...more rows of data here...
Data 1 Data 2 Data 3 Data 4

Output:

THead Tag in HTML

Note that if there is a need for two rows for the header of your table, both

element data can be added to one single element. Try not to add two element sections for one table. Observe one such example below, having two rows under the header section :

Example #2

Code:


Header 1 Row 1 Header 2 Row 1
Header 1 Row 2 Header 2 Row 2 Header 3 Row 2 Header 4 Row 2
Data 1 Data 2 Data 3 Data 4

Output:

THead Tag in HTML

Example #3

Code:


Header 1 Row 1 Header 2 Row 1
Header 1 Row 2 Header 2 Row 2 Header 3 Row 2 Header 4 Row 2
Data 1 Data 2 Data 3 Data 4

Output:

THead Tag in HTML

Observe that, though both the above codes generate the same output and using separate elements for two headers does get handled by some browsers. However, it is still a semantic error that should not be used in proper programming, and also it will be raised as a red flag by HTML validation services.

Example #4

Let’s see another example below. In the following example, we have created a table with a table body consisting of four rows of data. A header consists of one row of data set to a background color using CSS. The ,

or do not affect the default appearance of an HTML table; thus, a little help with CSS would suffice.

Code:


Time Table
Mon Tue Wed Thu Fri
Science Maths Hindi Hindi English
English Hindi Maths Social Science
Lunch
Science English Maths Hindi Social

Output: 

THead Tag in HTML

Attributes of THead Tag in HTML

The HTML element supports some following additional attributes.

  • align: This attribute aligns the content of an element and everything inside it. It uses left, right, center, justify and char as its value.
  • char: This attribute specifies alignment to the element content when align attribute is set to char.
  • valign: It specifies the vertical alignment of the content inside the element. It uses top, middle, bottom, or baseline as its values.
  • charoff: This attribute specifies an offset against the 1st character as specified with a char attribute; that is, when to align is set to char.
  • bgcolor: It helps set the background color of each cell inside element.

    Conclusion

    We saw how an element identifies column labels and not table data, holding the information about the headers and feeding it to the browsers, assisting technology with the content and its meaning.

The above is the detailed content of THead Tag in HTML. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
HTML in Action: Examples of Website StructureHTML in Action: Examples of Website StructureMay 05, 2025 am 12:03 AM

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

How do you insert an image into an HTML page?How do you insert an image into an HTML page?May 04, 2025 am 12:02 AM

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

HTML's Purpose: Enabling Web Browsers to Display ContentHTML's Purpose: Enabling Web Browsers to Display ContentMay 03, 2025 am 12:03 AM

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

Why are HTML tags important for web development?Why are HTML tags important for web development?May 02, 2025 am 12:03 AM

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.

Explain the importance of using consistent coding style for HTML tags and attributes.Explain the importance of using consistent coding style for HTML tags and attributes.May 01, 2025 am 12:01 AM

A consistent HTML encoding style is important because it improves the readability, maintainability and efficiency of the code. 1) Use lowercase tags and attributes, 2) Keep consistent indentation, 3) Select and stick to single or double quotes, 4) Avoid mixing different styles in projects, 5) Use automation tools such as Prettier or ESLint to ensure consistency in styles.

How to implement multi-project carousel in Bootstrap 4?How to implement multi-project carousel in Bootstrap 4?Apr 30, 2025 pm 03:24 PM

Solution to implement multi-project carousel in Bootstrap4 Implementing multi-project carousel in Bootstrap4 is not an easy task. Although Bootstrap...

How does deepseek official website achieve the effect of penetrating mouse scroll event?How does deepseek official website achieve the effect of penetrating mouse scroll event?Apr 30, 2025 pm 03:21 PM

How to achieve the effect of mouse scrolling event penetration? When we browse the web, we often encounter some special interaction designs. For example, on deepseek official website, �...

How to modify the playback control style of HTML videoHow to modify the playback control style of HTML videoApr 30, 2025 pm 03:18 PM

The default playback control style of HTML video cannot be modified directly through CSS. 1. Create custom controls using JavaScript. 2. Beautify these controls through CSS. 3. Consider compatibility, user experience and performance, using libraries such as Video.js or Plyr can simplify the process.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.