Filter (Advanced Search)
Downloads
1
Views
315
Video

HTML Table Column Width | Tables

Details

To set the size of a specific column, add the style attribute on a <th> or <td> element:


<!DOCTYPE html>
<html>
<head>
<title>HTML Table Column Width</title>
</head>
<body>
<h2>Set the first column to 70% of the table width</h2>

<table style="width:100%">
  <tr>
    <th>#</th>
    <th style="width:70%">Name of Student</th>
    <th>Class</th>
  </tr>
  <tr>
    <td>1.</td>
    <td>Taranpreet Singh</td>
    <td>6th</td>
  </tr>
  <tr>
    <td>2.</td>
    <td>Mehakpreet Kaur</td>
    <td>7th</td>
  </tr>
  <tr>
    <td>3.</td>
    <td>Veerpal Kaur</td>
    <td>8th</td>
  </tr>
  <tr>
    <td>4.</td>
    <td>Jasmeen</td>
    <td>9th</td>
  </tr>
  <tr>
    <td>5.</td>
    <td>Sonia</td>
    <td>10th</td>
  </tr>
  <tr>
    <td>6.</td>
    <td>Jaskaran Singh</td>
    <td>11th</td>
  </tr>
  <tr>
    <td>7.</td>
    <td>Arshdeep Kaur</td>
    <td>12th</td>
  </tr>
  
</table>

</body>
</html>


Output


Ad