表格在网页编程中使用非常的广泛,而且也非常的重要,下面我就将本人编程中所总结的有关表格的基本属性整理处理。
table标签的基本属性如下:
border:可以的取值为1和0,1代表有边框,0代表没有边框。
bordercolor:可以设置边框的颜色,值为颜色值。
bgcolor:设置表格的背景颜色
background:设置背景图片
tr:表示表格中的行标记,属性有align:左中右三个值
td:列标记,align属性可以设置内容的位置
th:是第一行的标题
valign属性可以设置th和td,可以取值Top或者Bottom。
callpadding:内容与单元格边框的间距
cellspacing:防止文本超出边框
如果要使单元格实现跨行或者跨列功能,使用属性colspan和rowspan.
实例代码:
<body>
<table border="1" bordercolor="red" bgcolor="#ff4646">
<caption>表格示例</caption>
<tr align="center">
<th>标题1</th>
<th>标题2</th>
<th>标题3</th>
</tr>
<tr>
<td align="left">左</td>
<td align="center">中</td>
<td align="right">右</td>
</tr>
<tr>
<td valign="top">top</td>
<td>center</td>
<td valign="bottom">bottom</td>
</tr>
</table>
</body>
单元格跨行
<table border="1" bordercolor="#1f1fff">
<caption>单元格的跨行</caption>
<tr>
<th>姓名</th>
<th colspan="2">电话</th>
</tr>
<tr>
<td>东腾</td>
<td>1301485237 1067225098</td>
</tr>
</table>
单元格跨列
<table border="1">
<caption>单元格跨列</caption>
<tr>
<th>姓名</th>
<th>电话</th>
</tr>
<tr>
<td rowspan="2">东腾</td>
<td>1301485237</td>
</tr>
<tr>
<td>1067225098</td>
</tr>
</table>
不足之处,还望指点!!!