centering with css

windows

Guest
i want to center a div in css. not center the text, center the whole thing. basically i want to make a page with a fixed width, but its centered. i think you like set margins and then make its position relative or something. anyhu, i know it can be done, how?margin: 0 auto;
width:xx;

margin centers it, but you need to set a width or it just spreads out and you won't see it centereddoes work. tried doing that to the body, and tried adding a main wrapper div and adding that, and niether worked. missing something?

edit. i screwed around with it, found something that worked. thanks.Just so everyone knows:

body {
text-align: center;
margin: 0;
padding: 0;
}

#wrapper {
margin: 0 auto;
width: 720px;
text-align: left;
}

<body>
<div id="wrapper>
<p>...</p>
</div>
</body>
 
Back
Top