HTML <th> widthProperty

HTML <th> Tag

Example

Header cell with predefined width:

<table border="1" width="100%">
  <tr>
    <th width="70%">Month</th>
    <th width="30%">Savings</th>
  </tr>
  <tr>
    <td>January</td>
    <td>$100</td>
  </tr>
  <tr>
    <td>February</td>
    <td>$80</td>
  </tr>
</table>

Try it Yourself »

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the width attribute.


Definition and Usage

HTML5 does not support the <th> width attribute. Use CSS instead.

In HTML 4.01, the width attribute of <th>Deprecated。

The width attribute specifies the width of a header cell.

Usually, the space a cell occupies is the space needed to display its content. The width attribute is used to set a predefined width for the cell.


Compatibility Notes

In HTML 4.01, the width attribute of <th> is deprecated. Please use CSS instead.

CSS Syntax: <th style="width:100px">

CSS Example: Setting the width of a table header cell.

In our CSS tutorial, you can find more aboutwidth attributeDetails.


Syntax

<th width="pixels|%">

Property value

Value Description
pixels Set the width value in pixels (for example, width="50").
% Set the width value as a percentage of the containing element (for example, width="50%").


HTML <th> Tagother extensions