效果:
代码:
<!-- CSS goes in the document HEAD or added to your external stylesheet -->
<style type="text/css">
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:11px;
<!-- #8FBC8F #333333-->
color:#8FBC8F;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
</style>
<!-- Table goes in the document BODY -->
<table class="gridtable">
<tr>
<th>Info Header 1</th><th>Info Header 2</th><th>Info Header 3</th>
</tr>
<tr>
<td>Text 1A</td><td>Text 1B</td><td>Text 1C</td>
</tr>
<tr>
<td>Text 2A</td><td>Text 2B</td><td>Text 2C</td>
</tr>
</table>
代码解释:
table.gridtable{} 部分定义css的gridtable类,指定字体家族、字体尺寸、颜色、边框宽度、边框颜色、边框折叠
table.gridtable th {}定义表头的边框宽度、内边距、边框风格-实线、边框颜色、背景颜色
table.gridtable td {}定义列的边框宽度、内边距、边框风格、边框颜色、背景颜色
<table>标签定义表格,其被应用上面定义的css类gridtable;
html表格还有三个标签:th-表头,tr-行,td-列;
3对tr标签定义了3行;
每个tr中包含3对td标签,定义了每行有三列;