Home > Web Front-end > CSS Tutorial > Detailed introduction to CSS basic style tables

Detailed introduction to CSS basic style tables

高洛峰
Release: 2017-03-26 11:27:49
Original
2109 people have browsed it

This article is mainly a detailed introduction to Css basic style tables. It has certain reference value. Interested friends can refer to it

a.Css table attributes can help us greatly improve tables. The appearance

b.Table border

<table>
    <tr>
        <th>姓名</th>
        <th>年龄</th>
        <th>性别</th>
    </tr>
    <tr>
        <td>小王</td>
        <td>20</td>
        <td>男</td>
    </tr>
    <tr>
        <td>小王</td>
        <td>20</td>
        <td>男</td>
    </tr>
    <tr>
        <td>小王</td>
        <td>20</td>
        <td>男</td>
    </tr>
</table>
Copy after login

This can generate a table without border effect

You can add a border to the table at this time

<table border = "1">
Copy after login

But this writing method cannot be applied to all tables

So you can choose to use Css style as a better way

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

At this time, you can see the final form of the table The outer blue outer border

can set the inside of the table:

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

A grouping selector is used here. That is, an id selector and three element selectors are combined, separated by commas

c. Collapse border

In the above table, double borders are displayed

This is obviously unreasonable

You can combine the double borders into one line

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

d. Table width and height

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

e.Table text alignment

#tb{
    width: 400px;
    height: 400px;
    border-collapse: collapse;
}
#tb,tr,th,td{
    border: 1px solid blue;
    text-align:center;
}
Copy after login

f.Table margin

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;
}
Copy after login

The above is the detailed content of Detailed introduction to CSS basic style tables. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
css
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template