How to set borders for tables in css

青灯夜游
Release: 2023-01-05 16:10:20
original
35265 people have browsed it

How to set borders for css tables: 1. Use the border attribute to add a border to the table element, the syntax "table{border:width style color;}"; 2. Use the border attribute to add a border to the td element, the syntax " td{border:width style color;}".

How to set borders for tables in css

The operating environment of this tutorial: Windows 7 system, CSS3&&HTML5 version, Dell G3 computer.

The default table has no borders

商品 价格
T恤 ¥100
牛仔褂 ¥250
牛仔库 ¥150
Copy after login

How to set borders for tables in css

We can add borders to the table through css.

Method 1: Set the border only for the table label

Set the border (border) style only for the table label, which will give the outermost table of the table a border. There is no border style generated inside the table.

Grammar:

table{
	border: 1px solid red;
}
Copy after login

Effect picture:

How to set borders for tables in css

##Method 2: Set border for td

Set the border style for the table td. The td within the table object will implement the border style, but the middle td will cause double borders.

Grammar:

td{
border: 1px solid red;
}
Copy after login

Effect picture:

How to set borders for tables in css

If you think the double line effect is not good-looking. You can set:

table {
        border-collapse: collapse;
        
}
Copy after login
Set the merged border model (merged border) for the table (table), the effect picture:

How to set borders for tables in css

(Learning video sharing:

css video tutorial)

The above is the detailed content of How to set borders for tables in css. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
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 [email protected]
Latest issues
Popular Tutorials
More>
Latest downloads
More>
web effects
Website source code
Website materials
Front end template
About us Disclaimer Sitemap
PHP Chinese website:Public welfare online PHP training,Help PHP learners grow quickly!