Home >Web Front-end >HTML Tutorial >Example of a solution for using margin:0 auto in HTML to prevent the entire page from being centered

Example of a solution for using margin:0 auto in HTML to prevent the entire page from being centered

高洛峰
高洛峰Original
2017-03-06 16:09:202649browse

Today I am writing a jsp page, and I have to adjust the

123xxx
no matter how I change this attribute, I can't get the page to be displayed in the center, and other styles also appear inexplicably. Problem

Later I found a solution to this problem:

It turns out that L-Blog does not add DTD before HTML by default, so IE interprets the document as HTML instead of XHTML.
The problem is not in the CSS but in the XHTML web page itself.
You need to add this code to make the above settings effective:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

If you want a more strict XHTML 1.0 Strict or XHTML 1.1, please check Related documents.
The above tests are based on Windows XP SP2 version IE6 and FireFox 1.0 final version.

It is recommended that if you need to use css style in the page, do not delete this line:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

Update For example, when using margin:0 auto in multiple html, the entire page is not centered. For related articles, please pay attention to 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