CSS Layout How to - Align wide block element to center








Question

We would like to know how to align wide block element to center.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
body {<!--from  w ww.j a  v  a  2s .c o  m-->
  background: #EEE;
  color: black;
}

#root {
  background: #FFFFFF;
  color: #000000;
  margin: 0 auto;
  width: 1008px;
}
</style>
</head>
<body>
<body>
  <div id="root">all content</div>
</body>
</body>
</html>

The code above is rendered as follows: