Learning coding means GreatToCode Be more than a Coder ! Greattocode , Join GreatToCode Community,1000+ Students Trusted On Us .If You want to learn coding, Then GreatToCode Help You.No matter what It Takes !


CODE YOUR WAY TO A MORE FULFILLING And HIGHER PAYING CAREER IN TECH, START CODING FOR FREE Camp With GreatToCode - Join the Thousands learning to code with GreatToCode
Interactive online coding classes for at-home learning with GreatToCode . Try ₹Free Per Month Coding Classes With The Top Teachers . HTML Table Headers

HTML Table Headers

 HTML tables can have headers for each column or row, or for many columns/rows.


EMILTOBIASLINUS
   
   
   
   
   
8:00  
9:00  
10:00  
11:00  
12:00  
13:00  
MONTUEWEDTHUFRI
8:00     
9:00     
10:00     
11:00     
12:00     
DECEMBER
   
   
   
   
   

HTML Table Headers

Table headers are defined with th elements, each th element represents a table cell.

Example

<table>
  <tr>
    <th>Firstname</th>
    <th>Lastname</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>
Try it Yourself »

Vertical Table Headers

To use the first column as table headers, define the first cell in each row as a th element:

Example

<table>
  <tr>
    <th>Firstname</th>
    <td>Jill</td>
    <td>Eve</td>
  </tr>
  <tr>
    <th>Lastname</th>
    <td>Smith</td>
    <td>Jackson</td>
  </tr>
  <tr>
    <th>Age</th>
    <td>94</td>
    <td>50</td>
  </tr>
</table>
Try it Yourself »

Align Table Headers

By default, table headers are bold and centered:

FirstnameLastnameAge
JillSmith50
EveJackson94

To left-align the table headers, use the CSS text-align property:

Example

th {
  text-align: left;
}
Try it Yourself »

Header for Multiple Columns

You can have a header that spans over two or more columns.

NameAge
JillSmith50
EveJackson94

To do this, use the colspan attribute on the <th> element:

Example

<table>
  <tr>
    <th colspan="2">Name</th>
    <th>Age</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
  <tr>
    <td>Eve</td>
    <td>Jackson</td>
    <td>94</td>
  </tr>
</table>
Try it Yourself »

You will learn more about colspan and rowspan in the Table colspan & rowspan chapter.


Table Caption

You can add a caption that serves as a heading for the entire table.

Monthly savings
MonthSavings
January$100
February$50

To add a caption to a table, use the <caption> tag:

Example

<table style="width:100%">
  <caption>Monthly savings</caption>
  <tr>
    <th>Month</th>
    <th>Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$50</td>
  </tr>
</table>
Try it Yourself »

Note: The <caption> tag should be inserted immediately after the <table> tag.


HTML Exercises

Test Yourself With Exercises

Exercise:

Add a table caption that says "Names".

<table>
  
  <tr>
    <th>First Name</th>
    <th>Last Name</th>
    <th>Points</th>
  </tr>
  <tr>
    <td>Jill</td>
    <td>Smith</td>
    <td>50</td>
  </tr>
</table>

Start the Exercise

Post a Comment

0 Comments

•Give The opportunity to your child with GreatToCode Kid's • Online Coding Classes for Your Kid • Introduce Your kid To the world's of coding
•Fuel You Career with our 100+ Hiring Partners, Advance Your Career in Tech with GreatToCode. •Join The Largest Tech and coding Community and Fast Forward Your career with GreatToCode. •10000+ Learner's+ 90 % placement Guarantee. • Learning Coding is Better with the GreatToCode community .
•Greattocode Kid's •GreatToCode Career •GreatToCode Interview •GreatToCode Professional •GreatToCode for schools •GreatToCode For colleges •GreatToCods For Businesses.
Are you ready to join the millions of people learning to code? GreatToCode Pass is your one-stop-shop to get access to 1000+ courses, top-notch support, and successful job placement. What are you waiting for? Sign up now and get your future in motion with GreatToCode Pass.

Join Arvind Upadhyay Succedo Event & Movement

Unlock Your True Potential!

Are you ready to transform your life and achieve the success you deserve?

Join us for an empowering experience!

Event Details:

Date: 25th October 2024

Time: 3 PM to 4 PM

Price/Ticket: Rs 100

Virtual Event

Lifetime Guidance

Pay just Rs 100 to join via UPI:

Pay via UPI

Register by emailing: ceoarvindenterprises@gmail.com

Chat with our team on WhatsApp for more information:

918080772353

Register Now Chat on WhatsApp

Event by Arvind Upadhyay.

Arvind Upadhyay is the author of over 100 books, a business and life coach, and famous for his self-help books, high-energy seminars, and workshops.

Attract Health, Wealth, and Success

Using the Law of Attraction

Are you struggling to become successful, despite having all the knowledge and skills?

It might be because you’re not using the most powerful principle known to mankind.

Join Our Virtual Event!

Available in Hindi and English

Date: 20th Oct 2024

Time: 10 AM to 11 AM

Pay just Rs 50 to join via UPI:

Pay via UPI

Register by emailing: ceoarvindenterprises@gmail.com

Chat with our team on WhatsApp for more information:

918080772353

Register Now Chat on WhatsApp

Event by Arvind Upadhyay.

Arvind Upadhyay is the author of over 100 books, a business and life coach, and famous for his self-help books, high-energy seminars, and workshops.