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

高洛峰
Release: 2017-03-06 16:09:20
Original
2463 people have browsed it

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">
Copy after login
Copy after login

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">
Copy after login
Copy after login

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!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!