ProfK
ProfK

Reputation: 51064

Centre Content Horizontally in Page

I would like to display all my content in a div that is 800px wide, centred in the page. That way, all browser window widths are catered for. How do I go about doing that?

Upvotes: 1

Views: 1543

Answers (2)

Reece
Reece

Reputation: 123

I would also recommend adding text-align:left; to the container div and adding text-align:center; to the body tag. Reason being that Internet Explorer 6.0 will not handle the auto margins.

body {
      text-align:center;}

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

Upvotes: 4

Raithlin
Raithlin

Reputation: 1764

Set your div CSS as follows:

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

Upvotes: 6

Related Questions