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

Steps to install MySQL using Docker under Linux

As a tester, you may often need to install some s...

In-depth explanation of modes and environment variables in Vue CLI

Preface In the development of actual projects, we...

Detailed explanation of Vue router routing

Table of contents 1. Basic use 2. Several points ...

Vue integrates Tencent Map to implement API (with DEMO)

Table of contents Writing Background Project Desc...

Detailed explanation of the relationship between Linux and GNU systems

Table of contents What is the Linux system that w...

canvas.toDataURL image/png error handling method recommendation

Problem background: There is a requirement to tak...

Angular Dependency Injection Explained

Table of contents Overview 1. Dependency Injectio...

Solution for using Baidu share on Https page

Since enabling https access for the entire site, ...

Example code for setting hot links and coordinate values ​​for web images

Sometimes you need to set several areas on a pict...

Example of adding multi-language function to Vue background management

Table of contents 1. First, configure the main.js...

Docker deploys nginx and mounts folders and file operations

During this period of time, I was studying docker...

nginx proxy_cache batch cache clearing script introduction

Preface: I used the official nginx proxy_cache as...

Vue-pdf implements online preview of PDF files

Preface In most projects, you will encounter onli...

Command to view binlog file creation time in Linux

Table of contents background analyze method backg...

A brief discussion on the efficiency of MySQL subquery union and in

Recent product testing found a problem that when ...