小码哥的IT人生

HTML <thead> 标签的 align 属性 详解

HTML基础 2023-07-14 09:05:33小码哥的IT人生shichen

HTML <thead> 标签的 align 属性

实例

下面的 HTML 表格将 thead 元素中的内容向左对齐:

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

 

完整实例【亲自试一试】:

<html>
<body>
<table border="1" width="100%">
  <thead align="left">
    <tr>
      <th>Month</th>
      <th>Savings</th>
    </tr>
  </thead>
    <tr>
      <td>January</td>
      <td>$100</td>
    </tr>
    <tr>
      <td>February</td>
      <td>$80</td>
    </tr>
</table>
</body>
</html>

可以使用本站在线JavaScript测试工具测试上述代码运行效果:http://www.phpcodeweb.com/runjs.html

定义和用法

align 属性规定 thead 元素中的内容的水平对齐方式。

浏览器支持

所有浏览器都支持 align 属性。

注释:IE 无法正确地处理 "justify" 值,IE 会以居中的方式进行处理。

注释:几乎没有浏览器能够正确地处理 "char" 值。

语法

<thead align="value">

属性值

描述
left 左对齐内容(默认值)。
right 右对齐内容。
center 居中对齐内容(th 元素的默认值)。
justify 对行进行伸展,这样每行都可以有相等的长度(就像在报纸和杂志中)。
char 将内容对准指定字符。

版权所有 © 小码哥的IT人生
Copyright © phpcodeweb All Rights Reserved
ICP备案号:苏ICP备17019232号-2  

苏公网安备 32030202000762号

© 2021-2024