Home  >  Article  >  Web Front-end  >  How to center the table in html

How to center the table in html

藏色散人
藏色散人Original
2021-04-12 09:23:4838235browse

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!

Statement:
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