We would like to know how to center div with auto margin.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
.center {<!--from ww w . j av a2 s . co m-->
margin: 0 auto;
width: 300px;
height: 100px;
background-color: #000
}
</style>
</head>
<body>
<body>
<div>
<div class="center"></div>
</div>
</body>
</body>
</html>
The code above is rendered as follows: