HTML <table> 标签的 align 属性
align 属性规定表格相对于周围元素的对齐方式。
通常来说,HTML 表格的前后都会出现折行。通过运用 align 属性,可实现其他 HTML 元素围绕表格的效果。
1. 语法
<table align="value">
属性值
值 | 描述 |
---|---|
left | 左对齐表格。 |
right | 右对齐表格。 |
center | 居中对齐表格。 |
2. 范例
一个右对齐的 HTML 表格:
<table border="1" align="right"> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$80</td> </tr> </table>
3. 兼容性注释
在 HTML 4.01 中,不赞成使用 body 元素的 align 属性;在 XHTML 1.0 Strict DTD 中,不支持 body 元素的 align 属性。
请使用 CSS 代替。
CSS 语法:<table style="float:right">
HTML <table> 标签的 bgcolor 属性:bgcolor 属性规定规定表格的背景颜色。语法:<body bgcolor="value">。color_name:规定颜色值为颜色名称的背景颜色(比如 "red")。hex_number:规定颜色值为十六进制值的背景颜色(比如 "#ff0000")。