How to center the div+css div but not the text inside:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/ xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" http://www.w3.org/1999/xhtml ">
<head>
<title>
do a test
</title>
<style type="text/css" rel="stylesheet">
body{
margin:0px;
}
#countainer{
margin:auto;
width:600px;
height:100%;
background-color:#cccccc;
}
</style>
</head>
<body>
<div id="countainer">
China
</div>
</body>
</html>
In fact, the most critical point here is: the value of margin:auto; in the attributes of the countainer class!
When I was testing just now, I found that <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional/ /EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<html xmlns=" http://www.w3.org/1999/xhtml ">
is also very important. If there is no such sentence, the display in IE browser will still be on the left. In Firefox and Google Chrome, the display will be Correct, after adding this sentence, all browsers will display correctly