Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

203
Views
How do i make a html table not have dynamic columns that change size in width depending on the amount of data in a <td>

I am trying to create a table that has equally sized columns which wont change depending on the length of the table data

enter image description here

In the picture the data under the heading "Titel" moves the second column further to the right compared to the other tables where "Titel" is shorter. This behaviour is not wanted but it seems to be the default.

I tried padding the first column but it doesn't change the behaviour at all. How can i achive a fixed size that doesnt push other columns away?

Here is an example code which gives the unwanted behaviour

<!DOCTYPE html>
<html>
<head>
<style>
table, th, td {
  border: 1px solid black;
  padding: 5px;
}
table {
  border-spacing: 15px;
}

    </style>
    </head>
    <body>
    
    <h2>Border Spacing</h2>
    <p>Border spacing specifies the space between the cells.</p>
    
    <table style="width:100%">
      <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>
      <tr>
        <td>John</td>
        <td>Doe</td>
        <td>80</td>
      </tr>
    </table>
    
    </body>
    </html>

I've tried setting width on the table and its columns, and also padding the table but it doesn't work.

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

With Bootstrap 4.0 you can use the sizing utilities classes for widths:

<thead>
     <tr>
           <th class="w-25">25</th>
           <th class="w-50">50</th>
           <th class="w-25">25</th>
     </tr>
</thead>

You can also use d-inline-block to prevent the default setting of display:flex.

about 4 years ago · Juan Pablo Isaza Report

0

I solved it by using style="table-layout:fixed" on the table and using bootstrap cols on the table headers.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!