Centering page using CSS

SpaceshipSpaceship
NamecheapNamecheap
Namecheap AuctionsNamecheap Auctions
Watch

MasterB

Awesomeâ„¢Established Member
Impact
3
Hey everyone, need some help here.
I'm designing a site for my group, and I'm having some problems. Most of all, dealing with the XHTML 1.0 Strict format that I'm using. This is my site being designed:
http://y1v.net/mbbsite/

In Internet Explorer, it looks fine. In Firefox, though, it is aligned to the left. I am currently using
Code:
<div style="text-align: center">
to center to center the entire contents of the body, but it seems this doesn't work in Firefox. Can anyone help me out?

The most important thing to me is to keep it XHTML 1.0 Strict, so I can't use
Code:
<div align="center">
or
Code:
<center>
tags. Thanks for the help.
 
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
On your CSS file under the div you want to be centered make this code:
Code:
margin-left: auto;
margin-right: auto;

This will center it in Firefox but IE sucks so you have this under body
Code:
text-align: center;

Then under everything you don't want the text to be aligned in the center for just use this code:
Code:
text-align: left;

Hope this helps.
 
0
Close
A slightly shorter version of above:

Code:
body {
text-align: center;
}

#wrap {
margin: 0 auto;
text-align: left;
}
 
0
Close
OH ...! Thanks For Kind Help...g1c9
 
0
Close
You can also go to www.bluerobot.com and find a thing on how to center with CSS.
 
0
Close
Appraise.net

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back