Today, I want to talk to you about how CSS sets the table border style, and the CSS style border for table is divided into 4 cases, the following is a detailed explanation of how these four situations need to be handled.
1. Set the border only for table
2. Set the frame for TD
3. Set table border for table and TD skills
4. Set the background for table and TD to achieve perfect table border
Here are a few of the above to implement the HTML table border style to explain and case demonstration. For the sake of observation, divcss5 all the case table is 1px solid line red border For example, table width is 400px, table is three column three row, the above four case table extra layer add a div box, respectively css named ". Table-a", ". Table-b", ". Table-c ",". Table-d ".
Set borders only on table table labels
Setting the border (border) style only on the table label will give the table a border at the outermost table and no border style inside the table.
The case details are as follows:
1. Corresponding CSS code
<style>. Table-a table{border:1px Solid #F00}//CSS comment: Set the red border style only for table labels */</style>
2. Corresponding HTML code fragment
<div class= "Table-a" > <table width= "" "border=" 0 "cellspacing=" 0 "cellpadding=" 0 "> <tr> <td Width= "" > Station name </td> <td width= "181" > URL </td> <td width= "A" > Description </td> </tr> <tr> <td>PHP</td> <td>www.php.cn</td> <td>php</td> </tr> <tr> <td>php</td> <td>www.php.cn</td> <td>php</td> </tr> </table> </ Div>
CSS to set the table border style of the method is these, the need for friends can be saved, but also please continue to follow the site of other updates.
Related reading:
How to set the margin property of CSS
What are the different ways to set the background color of a div
Div+css How to use