HTML <th> width 属性
标签" href="tag-main.html"><main>
<map>
<mark>
<menu>
<meta>
<meter>
<nav>
<noframes>
<noscript>
<object>
<ol>
<optgroup>
<option>
<output>
<p>
<param>
<pre>
<html>
<picture>
<progress>
<q>
<rp>
<rt>
<ruby>
<s>
<samp>
<script>
<section>
<select>
<small>
<source>
<span>
<strike>
<strong>
<style>
<sub>
<summary>
<sup>
<table>
<tbody>
<td>
<textarea>
< template>
<tfoot>
<th>
<thead>
<time>
<title>
<tr>
<track>
<tt>
<u>
<ul>
<var>
<video>
<wbr>
HTML <th> 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>
<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>
浏览器支持
所有主流浏览器都支持 width 属性。
定义和用法
HTML5 不支持 <th> width 属性。请使用 CSS 代替。
在 HTML 4.01 中,<th> 的 width 属性 已废弃。
width 属性规定表头单元格的宽度。
通常,单元格占用的空间就是它显示内容需要的空间。width 属性用于为单元格设置预定义的宽度。
兼容性注释
在 HTML 4.01 中,<th> 的 width 属性已废弃。请使用 CSS 代替。
CSS 语法:<th style="width:100px">
在我们的 CSS 教程中,您可以找到更多有关 width 属性 的细节。
语法
<th width="pixels|%">
属性值
| 值 | 描述 |
|---|---|
| pixels | 设置以像素计的宽度值(比如 width="50")。 |
| % | 设置以包含元素百分比计的宽度值(比如 width="50%")。 |
HTML <th> 标签