how to center a site without using the <center> element (depreciated)?

I would like my site to be centered when requested. So, regardless of the user's monitor size, the site is always in the center.

I tried using the HTML element <center>; it does work; but it breaks some part of the site.

Given the example below, what would you add to the CSS or HTML to display it in the center of the page?

thx
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>localhost</title>
<style type="text/css">
#container { width: 750px; }
#navigation { width: 100%; height: 1em; float: left; }
#navigation li { display: inline; }
#navigation li a { padding: .25em 1em; float: left;}
#main { width: 500px; float: left; }
#subsection { width: 200px; float: right; }
</style>
</head>
<body>
<div id="container">
<ul id="navigation">
<li><a href="">Home</a></li>
<li><a href="">About</a></li>
<li><a href="">Stuff</a></li>
</ul>
<div id="main">
<p>Duis aute irure dolor ullamco laboris nisi in reprehenderit in voluptate.
Ut labore et dolore magna aliqua. .</p>
<p>Sunt in culpa velit esse cillum dolore qui officia deserunt. Eu fugiat
nulla
pariatur. Excepteur sint occaecat lorem ipsum dolor sit amet, sunt in culpa.
Velit esse cillum dolore quis nostrud exercitation duis aute irure dolor.
Ut enim ad minim veniam, excepteur sint occaecat sunt in culpa.</p>
<p>In reprehenderit in voluptate. Quis nostrud exercitation ut labore
et dolore
magna aliqua. Excepteur sint occaecat lorem ipsum dolor sit amet, cupidatat
non proident. Qui officia deserunt quis nostrud exercitation velit esse cillum
dolore. In reprehenderit in voluptate ut aliquip ex ea commodo consequat.</p>
</div>
<div id="subsection">
<p>Omnis dolor repellendus. Et quasi architecto beatae vitae consectetur,
adipisci...</p>
</div>
</div>
</body>
</html>

Open in new window

epifanio67Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ovi_mihaiCommented:
body align="center"
or css body { text-align:center; }
should work
0
kdtreshCommented:
several options using div tags:

http://www.frontpagewebmaster.com/m-90322/tm.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Mark StegglesWeb DeveloperCommented:
Hello,

The correct way is to use auto margins like so:

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

Thanks
0
epifanio67Author Commented:
the link gave me the clues.... got the answer... thx

margin: auto

regards,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
CSS

From novice to tech pro — start learning today.