Center content horizontally on the page

I would like to display all my content in an 800px div centered on the page. This way, all browser window widths are satisfied. How can I do it?

+1


a source to share


2 answers


Set your div CSS like this:



#container {
  width: 800px;
  margin: 0 auto;
}

      

+6


a source


I would also recommend adding text-align:left;

to the container div and adding text-align:center;

to the body tag. This is because Internet Explorer 6.0 will not handle automatic fields.



body {
      text-align:center;}

#container {
      margin: 0px auto;
      text-align:left;
      width: 800px;}

      

+4


a source







All Articles