Aligning Site

Giarc86

Expert Member
Joined
May 28, 2008
Messages
1,243
Reaction score
4
I have a site designed in divs and aligned to the left of the page. Done in Visual Web Developer.
I want to centre the whole site in the middle of the page, is there any way to quickly do it without redesigning the entire site?

Thanks
 
Place it in a container, then use the following HTML & CSS to align that to the center:

HTML:
<div id="container"></div>

CSS:
#container {
margin: 0 auto;
width: [as per requirement]px;
}
 
Yeah, always place your site inside one main div.

I usually use this code:

#container {
position: relative;
width: 800px;
margin: auto;
}
 
Ok thanks alot, that helped.. but how do i get the entire site to move up so its flush with the top of the browser ie no white space showing above the site
also how would i get the table to not show the gaps between the table places you see in design view, want it to be flush but theres gaps around each cell

Thanks
 
Last edited:
u need to set the margin to be zero

<body topmargin="0" leftmargin="0">
 
or if you're sticking to xhtml/css guidelines, create a style for body with margin-top:0 and margin-bottom:0.
 
I usually copy and paste this as soon as i start a site:

body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size:12px;
}

And as for your tables, just make sure that in your table tag you have:

<table cellpadding="0" cellspacing="0"></table>
 
Top
Sign up to the MyBroadband newsletter
X