ITS
ITS

Reputation: 31

Different width `th` & `td` in Table

My problem is to put for example th at 50px and td at 500px, is this at least possible?

For my problem, i use datatable but so that most people can be reply i share a simply code :

.abc {
  width: 500px;
}

.def {
  width: 50px;
}
<head>
  <title> Data Table </title>

</head>

<body>
  <table border="1">
    <thead>
      <tr>
        <th>dkjg</th>
        <th class="def">fdsg</th>
        <th>dsgs</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>sdkhgdlg</td>
        <td class="abc">dsghj</td>
        <td>dfsjhn</td>
      </tr>
      <tr>
        <td>sdkhgdlg</td>
        <td class="abc">dsghj</td>
        <td>dfsjhn</td>
      </tr>
    </tbody>
  </table>

Upvotes: 0

Views: 1541

Answers (1)

kevenlolo
kevenlolo

Reputation: 304

No, it's not possible. All columns in the table will always have the same width.

You can possibly do this by declaring two separate tables. Table 1for the header and table 2 for the contents.

Upvotes: 4

Related Questions