How Do I automatilly center align all pages of website for all Browser sizes

They have: 4 posts

Joined: Jul 2009

Hi all:

I know this should be an easy task, but I am having problems finding my answer online.

Right now all of my web pages align to the left of any browser I check.

How do I make each page automatically center on the screen, no matter which browser or computer screen (like this webmaster forum page, for example).

Thanks you in advance.

Randy

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Can you post a link so we can see how your site is built?

The short answer is to put margin: 0 auto; on your containing div.

They have: 4 posts

Joined: Jul 2009

It did not center background...

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Can you post a link please? It's hard to tell what's happening when we can't see the site.

They have: 4 posts

Joined: Jul 2009

SeattleLightRail.net (thank you)...

Megan's picture

She has: 11,421 posts

Joined: Jun 1999

Right, this is tables and you don't have a containing div! margin: 0 auto; on the body works in Firefox - not sure about IE (see webwiz's comments on that)

He has: 629 posts

Joined: May 2007

You have an incomplete DOCTYPE that's putting your page in "quirks" mode. For Internet Explorer, that means all versions behave like version 5.5.

FWIW you can get old IE to center your table by adding "text-align: center;" to the BODY style.

P.S. All those inline styles will eventually drive you mad. Styles belong in a separate file.

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

He has: 629 posts

Joined: May 2007

Actually that table will center, given half a chance. The width specified on the BODY tag means that the table is centering on 795px. Take the width off the BODY and the table will center on the window.

To get the banner background image centered, apply 'background-position: center;' to it.

Cordially, David
--
delete from internet where user_agent="MSIE" and version < 8;

They have: 4 posts

Joined: Jul 2009

Thanks David!

I will give it a shot tomorrow... weekend has arrived and I am pooped. Seattle Light Rail Opens tomorrow morning at 10:00 am for the Grand Poobah!

Have an awesome weekend!!!

James Walter's picture

They have: 5 posts

Joined: Aug 2009

I think you have use CSS or the method Mr. Webwiz mention is also good to use but I prefer to use CSS because linking a CSS file to page is much easier to edit in future as compare to coding in-line css in pages so I suggest you to move all the designing to CSS because it also help the user to view your site who have low speed internet connection and its a plus point for your site. Thanks!

They have: 10 posts

Joined: Aug 2009

If you add align="center" within the parent table then I think the page will center align. I myself align pages in this way. Hope it works for you.

They have: 8 posts

Joined: Sep 2009

I agree with Jaime.adding align centre in the parent table has also worked in my case.

They have: 3 posts

Joined: Sep 2009

take the main table and give center option
{{link removed}}

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.