content" tag; 2. Add the "margin:0 auto attribute;" to the div to automatically adjust the center."/> content" tag; 2. Add the "margin:0 auto attribute;" to the div to automatically adjust the center.">

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

How to center div in html

藏色散人
藏色散人 Original
2021-05-24 11:02:33 37646browse

htmlHow to center the div: 1. Center the div by adding the "bacbf9e1ad7f40415ce1670e31edfee3contentadca8a5fa06ffeafb062c2e3f274b930" tag; 2. Add the "margin:0 auto attribute;" to the div to automatically adjust it Centered.

How to center div in html

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

There are two methods for DIV centering:

1. The simple and quick method is to add the bacbf9e1ad7f40415ce1670e31edfee3contentadca8a5fa06ffeafb062c2e3f274b930 tag.

Example:

   center居中 
我要居中啦

2. Add the margin:0 auto attribute to the div; automatically adjust the center.

Example 2:

   margin居中  
我是div,我居中啦...

Recommended tutorials:html video tutorial,css video tutorial

The above is the detailed content of How to center div 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