Hello,
I have a quick n easy CSS question.
I want to make a website that is fixed to 800px width.
What is the best, cross browser compatible way, to center it ?
Is their a better way of doing it than this ?
html
head
titletest/title
/head
body
style
#test
{
width: 800px;
}
/style
div id=base
Hi Lee,
The best way to center a website is to center the body then add a left and
right auto margin on your wrapper div. In the wrapper div you should set the
text-align back to left otherwise all your text will be centered:
body {
text-align:center;
}
#wrapper {
margin:0 auto;
Arlen Walker wrote:
On Feb 7, 2008, at 3:50 AM, Lee Bettridge wrote:
Is their a better way of doing it than this ?
Oh great googily-moogily yes.
CSS
html { text-align: center; }
body { width: 800px; margin-right: auto; margin-left: auto; text-
align: left; }
(Why use a wrapper div
Arlen Walker wrote:
(Why use a wrapper div when you have one built in to the document
structure?)
Well, if we don't use a wrapper div it'll only work in standard mode,
in which case the 'text-align: center;' on html and 'text-align: left;'
on body won't do anything and are better left out.
A
On Thu, 7 Feb 2008 08:42:46 -0700, Geoffrey Hoffman wrote:
If you have a div id wrapper with width:800px margin:0 auto; isn't the text-
align:center redundant? I've only ever used
#wrapper {
margin:0 auto;
width:800px;
text-align:left;
}
I've never put text-align:center on body.
The
If you have a div id wrapper with width:800px margin:0 auto; isn't the
text-align:center redundant? I've only ever used
#wrapper {
margin:0 auto;
width:800px;
text-align:left;
}
I've never put text-align:center on body.
Actually all you need is to specify a width (it can be relative or