cellspacing和cellpadding学习

cell指表格的内容
cellspaceing:表格里单元格之间的距离(类似div margin 外补丁)
cellpadding:表格里单元格空白部分(类似div padding 内补丁)

 cellspacing和cellpadding学习

<html>
	<head>
	
	</head>
	<body>
		<table border="1" cellspacing="10px" cellpadding="20px">
			<tr>
				<td>第一个</td>
				<td>第二个</td>
			</tr>
			<tr>
				<td>第一个</td>
				<td>第二个</td>
			</tr>
		</table>
			
		
	</body>
</html>

 

 border-collapse 属性设置表格的边框是否被合并为一个单一的边框,还是象在标准的 HTML 中那样分开显示

separate:分开,默认

collapse:合并,cellspacing和cellpadding样式失效

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta http-equiv="Content-Language" content="zh-cn" />

<meta name="robots" content="all" />

<meta name="author" content="w3school.com.cn" />
<meta name="Copyright" content="Copyright W3school.com.cn All Rights Reserved." />
<meta name="MSSmartTagsPreventParsing" content="true" />
<meta http-equiv="imagetoolbar" content="false" />

<link rel="stylesheet" type="text/css" href="/c3.css" />
<link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />

<title>CSS border-collapse 属性</title>
</head>

<body class="html">
<table style="border-collapse:collapse" border="1" width="200" cellspacing="30">
	<tr>
		<td>11</td>
		<td>12</td>
		<td>13</td>
	<tr>
	<tr>
		<td>21</td>
		<td>22</td>
		<td>23</td>
	<tr>
</table>

<table style="border-collapse:separate" border="1" width="200" cellspacing="30">
	<tr>
		<td>11</td>
		<td>12</td>
		<td>13</td>
	<tr>
	<tr>
		<td>21</td>
		<td>22</td>
		<td>23</td>
	<tr>
</table>
</body>

 

 备注:<!DOCTYPE 不能少,否则看不到效果

你可能感兴趣的:(padding)