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:
Example:
<!DOCTYPE HTML><HTML><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8" /><title>Add a border to a table</title><styletype= "Text/css">Table TR td,th{Border:1px solid #000;}</style></Head><Body><TableSummary=""> <TR> <th>Class</th> <th>Number of students</th> <th>Average score</th> </TR> <TR> <TD>Class One</TD> <TD>30</TD> <TD>89</TD> </TR> <TR> <TD>Class Two</TD> <TD>35</TD> <TD>85</TD> </TR> <TR> <TD>Class Three</TD> <TD>32</TD> <TD>80</TD> </TR></Table></Body></HTML>
Use CSS styles to add a border to a table