CSS Basic style ———— table

Source: Internet
Author: User

A.css Table properties can help us to greatly improve the appearance of the table

B. Table border

<table>    <tr>        <th> Name </th>        <th> Age </th>         <th> Sex </th>    </tr>    < Tr>        <td> Xiao Wang </td>         <td>20</td>        <td> male &LT;/TD >    </tr>    <tr>         <td> Xiao Wang </td>        <td>20</td>         <td> Men </td>    </tr>     <tr>        <td> Xiao Wang </td>         <td>20</td>        <td> male </td>     </tr></table>

This creates a table with no border effect.

You can now add a border to the table

<table border = "1" >

But this notation does not apply to all of the table

So you can choose to use CSS styles as a better way to

<table id= "TB" > #tb {border:1px solid blue;}

You can see the outermost blue outer border of the table.

You can set the inside of the table:

#tb, tr,th,td{border:1px solid blue;}

The group selector is used here. That is, an ID selector and a 3 element selector are grouped together, separated by commas


C. Folding borders

In the table above, a bilateral box is displayed

This is obviously unreasonable.

You can synthesize a line between the two sides.

#tb, tr,th,td{border:1px solid blue; Border-collapse:collapse;}


D. Table width height

#tb {width:400px;    height:400px; Border-collapse:collapse;} #tb, tr,th,td{border:1px solid blue;}


E. Table text alignment

#tb {width:400px;    height:400px; Border-collapse:collapse;}    #tb, tr,th,td{border:1px solid blue; Text-align:center;}


F. Table padding

G. Table Color

#tb {width:400px;    height:400px; Border-collapse:collapse;}    #tb, tr,th,td{border:1px solid blue;    Text-align:center; Background-color:aqua;}



CSS Basic style ———— table

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.