Create a table using the table element
table element has the following common attributes
Attributes |
meaning |
border |
Set the table border width |
width |
Set the table width |
height |
Set the length of the table |
cellpadding |
Padding set the table |
cellspacing |
Set the table margins |
inside the table element
element |
meaning |
caption |
Table title |
th |
Table Name |
tr |
Table row |
td |
Cell |
thead |
Distinguished head table |
tbody |
The main distinction between table |
tfood |
Distinction bottom of the table |
colgroupp、col |
Set different color style columns |
Property td element
Attributes |
meaning |
colspan |
Set cell interbank |
rowspan |
Set cell across columns |
Example:
<div style="margin: 30px 500px auto;text-align: center">
<table border="1" width="300" >
<thead>
<caption>职业调查</caption>
<th colspan="3">详情表</th>
</thead>
<tbody>
<colgroup>
<col bgcolor="#f79d03">
<col bgcolor="#ffd4f5">
<col bgcolor="e80063">
</colgroup>
<tr>
<td>姓名</td>
<td>职业</td>
<td>性别</td>
</tr>
<tr>
<td>小明</td>
<td>学生</td>
<td>男</td>
</tr>
<tr>
<td>张三</td>
<td>教师</td>
<td>男</td>
</tr>
<tr>
<td>静静</td>
<td>教师</td>
<td>女</td>
</tr>
</tbody>
<tfoot>
<tr>
<td colspan="3">总计3人</td>
</tr>
</tfoot>
</table>
</div>
result
Inside and outside of the table is not the default margins combined to form a single-frame need to use
border-collapse: collapse attribute values
Example:
<style>
table,td{
border: 1px solid #0D9AFE;
}
table{
width: 1000px;
height: 400px;
border-collapse: collapse;
margin: 0 auto;
text-align: center;
background-color: #1f79a7;
}
</style>
<body>
<table>
<tr>
<td colspan="5">学生管理信息表</td>
</tr>
<tr>
<td >id</td>
<td>姓名</td>
<td>年龄</td>
<td>性别</td>
<td>爱好</td>
</tr>
<tr>
<td>id</td>
<td>姓名</td>
<td>年龄</td>
<td>性别</td>
<td>爱好</td>
</tr>
</table>
</body>
Results Figure