Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4038758
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:30:45+00:00 2026-05-20T12:30:45+00:00

I have a table with thead, tbody and tfoot. The css value for display

  • 0

I have a table with thead, tbody and tfoot.
The css value for display is block – enables adding a scrollbar to the body and scroll the rows while the thead and tfoot stay in place.
The TD tags widths are not fixed as the tables width changes according to the width of the TD.
I would like to align the thead’s TH tags with the tbody’s TD tags.

How can this be done?
(CSS or JQuery)

Edit:
The target browser is Google – Chrome!

And adding a slight twist, the Table is RTL.

The CSS:

tbody{
    display: block;
    overflow: auto;
}

thead, tfoot{
    display: block;
}

The HTML:

    <table>
        <caption>My Table</caption>
        <thead>    
            <tr><th>Col1</th><th>Col2</th></tr>
        </thead>
        <tbody>    
            <tr><td>Cell11</td><td>Cell12</td></tr>
            <tr><td>Cell21</td><td>Cell22</td></tr>
            <tr><td>Cell31</td><td>Cell32</td></tr>
            <tr><td>Cell41</td><td>Cell42</td></tr>
            <tr><td>Cell51</td><td>Cell52</td></tr>
            <tr><td>Cell61 Is Wide</td><td>Cell62</td></tr>
        </tbody>
        <tfoot>
            <tr><th>6 Rows</th><th></th></tr>
        </tfoot>                
    </table>

You can try it using this jsFiddle.

Thanks and be happy.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T12:30:46+00:00Added an answer on May 20, 2026 at 12:30 pm

    Use JS or jQuery to access the offsetWidth of the cells in the first row of the tbody and then set those as explicit width styles for the th. You can iterate the row in the tbody and head in unison by using the index from one iteration to access the element in the other.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table: <table class=products> <thead>...</thead> <tfoot>...</tfoot> <tbody id=the-list> <tr id=order-0> <th scope=row
I have a table which looks like this: <table id='t'> <thead> .... </thead> <tbody
A table that extends onto multiple printed pages will have its thead and tfoot
Is there any Inheritance problem with <table> , tr th td tbody thead tfoot
I have this table : <table> <thead> <tr> <th>Quantity</th> <th>&nbsp;</th> <th>Price</th> <th>Sum</th> </tr></thead> <tbody>
I Have Table with multiple columns and rows, Example, <table> <thead> <tr> <th>Head 1</th>
Tables in HTML can have footers : <TABLE> <THEAD><TR><TD>Your header goes here</TD></TR></THEAD> <TFOOT><TR><TD>Your footer
I have a table with a thead and couple of tr in a tbody
I have a table made up of thead and tbody elements. I have some
I have a table with a code like this: <table cellpadding=6 rules=groups frame=no> <thead>

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.