...

View Full Version : Centering my content



whizard
01-27-2005, 08:17 PM
Hi

I am developing a page best fit for 1024x768 screen resolutions, but I want 800x600 screens to work with it too. Therefore, I have the content only 760px wide, so that on an 800x600 screen, it fills the entire browser window, but on 1024x768, there is gray space around the edges. I want to center the table that holds all my content, but I don't want to use absolute positioning, because I want the page always to be centered, even if the window isn't maximized all the way. The reason I don't just use align=center in the table tag, is that I want the page to be XHTML Strict, which doesnt allow the align attribute.

Dan Barr

bazz
01-27-2005, 08:37 PM
You using css? I would use a div and give it the css of, margin : auto auto; to center it and, either give the div a fixed width or use padding, to vary the whitespace either side.

bazz

Graft-Creative
01-27-2005, 08:42 PM
Hi

I am developing a page best fit for 1024x768 screen resolutions, but I want 800x600 screens to work with it too. Therefore, I have the content only 760px wide, so that on an 800x600 screen, it fills the entire browser window, but on 1024x768, there is gray space around the edges. I want to center the table that holds all my content, but I don't want to use absolute positioning, because I want the page always to be centered, even if the window isn't maximized all the way. The reason I don't just use align=center in the table tag, is that I want the page to be XHTML Strict, which doesnt allow the align attribute.

Dan Barr

Yep, like Bazz said, wrap your table in a <div> like this
css:


div#container {
width: 760px;
margin: 0 auto;
}


You'll also need to add this to your body tag in css:


body {
text-align: center;
}


Well that's how I do it anyway.

Gary

whizard
01-27-2005, 08:45 PM
Thx so muuch!

Dan



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum