Latest web development tutorials

HTML th width attribute

HTML th tag Reference Manual HTML <th> tag

Examples

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"

Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support width attribute.


Definition and Usage

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

In HTML 4.01, <th> The width attribute obsolete .

width attribute specifies the width of the table header cell.

Typically, the space occupied by the cell is that it requires the contents of display space. width property is used to set up predefined cell width.


Compatibility Notes

In HTML 4.01, <th> The width attribute is deprecated. Use CSS instead.

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

CSS Example: set the width of the header cell

In our CSS tutorial you can find more information about the width attribute details.


grammar

<th width="pixels|%">

Property Value

描述
pixels 设置以像素计的宽度值(比如 width="50")。
% 设置以包含元素百分比计的宽度值(比如 width="50%")。


HTML th tag Reference Manual HTML <th> tag