Solution to the problem of the entire page not being centered when using margin:0 auto in HTML

Solution to the problem of the entire page not being centered when using margin:0 auto in HTML
I wrote a jsp page today. I tried to adjust <div style="margin:0 auto">123xxx</div> but it didn't make the page display in the center. And other styles also had inexplicable problems.

Later I found the 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 with CSS but with the XHTML pages themselves.
You need to add the following code to make the above settings effective:

Copy code
The code is as follows:

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

If you want the stricter XHTML 1.0 Strict or XHTML 1.1 please refer to the relevant documents.
The above tests are based on IE6 and FireFox 1.0 final version on Windows XP SP2.

It is recommended that if you need to use CSS styles on the page, do not delete this line:

Copy code
The code is as follows:

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

<<:  Detailed explanation of the use and underlying principles of MySQL table partitions

>>:  Detailed explanation of the significance of standard commit msg in JavaScript development

Recommend

js to realize a simple puzzle game

This article shares the specific code of js to im...

Linux uses join -a1 to merge two files

To merge the following two files, merge them toge...

Brief analysis of the various versions of mysql.data.dll driver

Here is the mysql driver mysql.data.dll Notice: T...

Use xshell to connect to the Linux server

Benefits of using xshell to connect to Linux We c...

React nested component construction order

Table of contents In the React official website, ...

How to use CSS3 to implement a queue animation similar to online live broadcast

A friend in the group asked a question before, th...

A brief discussion on the calculation method of key_len in mysql explain

The MySQL explain command can analyze the perform...

Implementation of services in docker accessing host services

Table of contents 1. Scenario 2. Solution 3. Conc...

WeChat applet realizes horizontal and vertical scrolling

This article example shares the specific code for...

HTML line spacing setting methods and problems

To set the line spacing of <p></p>, us...

Nginx reverse proxy forwards port 80 requests to 8080

Let's first understand a wave of concepts, wh...

MySQL 8.0 installation tutorial under Linux

This article introduces how to install MySQL 8.0 ...