Home > Web Front-end > CSS Tutorial > How to set table spacing in css

How to set table spacing in css

醉折花枝作酒筹
Release: 2023-01-05 16:08:15
Original
14324 people have browsed it

How to set the table spacing in css: 1. Use the padding attribute to style the td element of the table, with the syntax "td{padding:value}"; 2. Use the cellpadding attribute directly within the table tag, with the syntax " cellpadding:value".

How to set table spacing in css

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

Create a new html file, named test.html, to explain controlling the spacing of table cells in css.

How to set table spacing in css

In the test.html file, use the table tag to create a table, and use the border attribute to set the border of the table to 1px.

How to set table spacing in css

In the test.html file, use the tr and td tags to create a table with two rows and two columns. The code is as follows:

How to set table spacing in css

How to set table spacing in css

##In the test.html file, write the tag. The css style of the page will be written in this tag. Inside.

How to set table spacing in css

In the css tag, set the style of the td element of the table, and use the padding attribute to set the spacing of the cells to 10px, that is, the inner margin of the cell is 10px.

How to set table spacing in css

In addition to the above method, you can also use the cellpadding attribute to set it directly in the table tag to define the cell spacing.

How to set table spacing in css

Open the test.html file in the browser to check the effect.

How to set table spacing in css

Recommended learning:

css video tutorial

The above is the detailed content of How to set table spacing in css. 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