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.
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.
In the test.html file, use the table tag to create a table with two rows and two columns for testing.
In the test.html file, add a class attribute to the table tag for setting the css style below.
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.
In the css tag, set the margin attribute to 0 auto to center the table.
Open the test.html file in the browser to check the effect.
[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!