本系列博客汇总在这里:JavaWeb_HTML 汇总


一、表格标签(table)

属性

  1. border:表格的边框,默认是 0。
  2. width:表格的宽度;既可以给像素,还可以给百分比(占整个屏幕)。
  3. height:表格的高度;既可以给像素,还可以给百分比(占整个屏幕)。
  4. align:水平位置 left,center,right。
  5. 子标签(caption):表格的标题。

二、表格的行标签(tr)

子标签

  1. th:标题列标签,加粗并居中。
  2. td:每一行的列标签,单元格,默认是居左。

三、表格边框的设置

  1. border:表格的外边框粗细。
  2. cellspacing:表格的内边框粗细,单元格直接的间距。
  3. cellpadding:设置文字到单元格的距离。

四、表格相关颜色的设置

  1. bordercolor:边框颜色。
  2. bgcolor:背景色。

五、表格的内容的位置设置

  1. align:文字的水平位置 left,center,right。
  2. valign:文字的垂直位置 top,middle,bottom。

六、示例

<html>
	
	<head>
		<title>www.weiyuxuan.com</title>		
	</head>
	
	<body>
		
		<h1>HTML表格标签</h1>
		
		<table border="20" width="80%" height="30%" align="center" cellspacing="0" cellpadding="30" bgcolor="yellow" bordercolor="red">
			
			<caption>梁山好汉</caption><!--标题-->
			
			<tr><!--表头-->
				<th>姓名</th>
				<th>地址</th>
				<th>年龄</th>
			</tr>
			
			<tr align="center"><!--第一行(下面所有行都居中)-->
				<td>宋江      </td><!--第一列-->
				<td>山东郓城  </td><!--第二列-->
				<td>32        </td><!--第三列-->
			</tr>
			
			<tr><!--第二行-->
				<td align="center">晁盖  </td><!--该行居中-->
				<td>石碣村               </td>
				<td>35                   </td>
			</tr>
			
			<tr><!--第三行-->
				<td>武松     </td>
				<td>阳谷县   </td>
				<td>26       </td>
			</tr>
			
		</table>
		
	</body>
	
</html>

JavaWeb_HTML(7)_HTML 的表格_背景色

如有错误,欢迎指正!