
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Create Table Header in HTML
To create table header in HTML, use the <th>?</th> tag. A table header tag is surrounded by the table row <tr>?</tr>. The <tr> tag is surrounded by the <table> tag. A table consist of a rows and columns, which can be set using one or more <tr>, <th>, and <td> elements. Use the style attribute to add CSS properties for adding a border to the table.
A table row is defined by the <tr> tag. To create table header, use the <th> tag. Just keep in mind that you can only have a single heading in a table.
Syntax
Following is the syntax to create table header in HTML.
<table> <tr> <th> Name</th> <th>RollNo</th> </tr> </table>
Example
Following is the example program to create header in HTML.
<!DOCTYPE html> <html> <style> table, th, td { border:1px solid black; } </style> <body> <h2>Tables in HTML</h2> <table> <tr> <th>Name</th> <th>RollNo</th> </tr> <tr> <td>Jason</td> <td>28</td> </tr> </table> </body> </html>
Now we try to extend the table headers in the table.
Example
Following is the example program to extend the table headers.
<!DOCTYPE html> <html> <style> table, th, td { border:2px solid black; } </style> <body> <h2>Tables in HTML</h2> <table> <tr> <th>Employee Name</th> <th>Employee Id</th> <th>Email</th> <th>Address</th> <th>Mobile Numbeer</th> <th>Employee Dept</th> </tr> <tr> <td>Jason</td> <td>28</td> <td>Jason@gmail.com</td> <td>Ecil</td> <td>7674897385</td> <td>Content Developer</td> </tr> </table> </body> </html>
Example
Following is another example program to create table in HTML.
<!DOCTYPE html> <html> <head> <title>How to create table heading in HTML?</title> <style> table, th, td { border: 0.5px solid green; } </style> </head> <body> <h2>How to create table heading in HTML?</h2> <p>We can create table heading by using <b>th(table heading)</b> tag</p> <table> <caption>Employee login time...</caption> <th></th> <th>Monday</th> <th>Tuesday</th> <th>Wednesday</th> <th>Thursday</th> <th>Friday</th> <th>Saturday</th> <th>Sunday</th> <tr> <th>Nikhil</th> <td>9:00 AM</td> <td>9:10 AM</td> <td>9:05 AM</td> <td>10:00 AM</td> <td>9:30 AM</td> <td>Week off</td> <td>Week off</td> </tr> <tr> <th>Prudhvi</th> <td>9:10 AM</td> <td>9:00 AM</td> <td>9:05 AM</td> <td>10:20 AM</td> <td>9:30 AM</td> <td>Week off</td> <td>Week off</td> </tr> <tr> <th>Krishna</th> <td>Leave</td> <td>Leave</td> <td>Leave</td> <td>Leave</td> <td>10:30 AM</td> <td>Week off</td> <td>Week off</td> </tr> </table> </body> </html>