Use CSS styles to add a border to a table
Table tables do not have a border before they are added to the CSS style. This does not facilitate our later merging of cell knowledge points, so in this section we add some styles to the table and add a border to it.
Add the following code to the right-hand code Editor:
<style type= "Text/css" >table tr td,th{border:1px solid #000;} </style>
The above code is in CSS style code (explained in detail later), for th
the td
cell to add a black border with a thickness of one pixel.
The result window shows the result style:
:
<! DOCTYPE html>
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> add a border to a table </title>
<style type= "Text/css" >
Table TR td,th{border:1px solid #000;}
</style>
<body>
<table summary= "" >
<tr>
<th> class </th>
<th> Number of students </th>
<th> Average Results </th>
</tr>
<tr>
<td> class </td>
<td>30</td>
<td>89</td>
</tr>
<tr>
<td> Class II </td>
<td>35</td>
<td>85</td>
</tr>
<tr>
<td> Three Classes </td>
<td>32</td>
<td>80</td>
</tr>
</table>
</body>
Use CSS styles to add a border to a table