sark9012
sark9012

Reputation: 5737

Attempting to centre the page

Never had a problem trying to do this before.

I am attempting to centre the entire page.

Some code:

body{
margin:0;
padding:0;
color:#333333;
font-family: "lucida grande",tahoma,verdana,arial,sans-serif;
font-size:0.85em;
}

#container{
width:960px;
float:left;
margin:0 auto;
}

Is there anything wrong with that? Anyone got any general problems it could be?

Upvotes: 0

Views: 50

Answers (2)

Justus Romijn
Justus Romijn

Reputation: 16019

The float:left should not be there. If you have trouble with showing floated elements in your container, you might want to add overflow: hidden; so the container expands when it has floated children in it.

For older versions of IE (below 7) margin: 0 auto is not supported: Add text-align: center; to your body and text-align: left; to your container to fix that.

Upvotes: 1

thirtydot
thirtydot

Reputation: 228182

You must remove float: left from #container. Other than that, it's fine.

Upvotes: 6

Related Questions