How to center the table in html

藏色散人
Release: 2023-01-04 09:36:00
Original
38383 people have browsed it

How to center the table in HTML: First create an HTML sample file; then use the table tag to create a table with two rows and two columns; then add a class attribute to the table tag; and finally set the margin attribute to " 0 auto" is enough.

How to center the table in html

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

htmlHow to center the table on the page

Create a new html file, named test.html, to explain how to center the table on the page in html.

How to center the table in html

In the test.html file, use the table tag to create a table with two rows and two columns for testing.

How to center the table in html

In the test.html file, add a class attribute to the table tag for setting the css style below.

How to center the table in html

In the css tag, set the style of the table through class, and define the width of the table to be 100px and the height to be 100px.

How to center the table in html

In the css tag, set the margin attribute to 0 auto to center the table.

How to center the table in html

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

How to center the table in html

[Recommended learning: css video tutorial]

The above is the detailed content of How to center the table in html. 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 admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template