Forum Moderators: open
align attribute is now deprecated, so the code is not future-proof and will not validate. Here's one approach:
div {
margin:0 auto;
}
Drawback: IE5 doesn't support properly
Here's another, assuming a 700 px width div:
div {
width:700px;
position: absolute;
left:50%;
top:0;
margin-left:-350px;
}
That last one is pretty clever -- absolute position in the exact center, but then negative left margin to move the div back to the left by half its width. You get half on each side of the center line.
Drawback: NN4 does not handle it correctly.
Poke around in our CSS forum -- lots of posts about this. Here's one thread on the topic:
[webmasterworld.com...]
They are not recommended for use, and are an indication of an amature web designer.
Or one who knows his audience will appreciate such things! :)
Seriously, there are legitimate uses for colored scrollbars. For instance, though I won't use them for the main scrollbars, I have no qualms about coloring the scrollbars on a scrolling div.
Do any of the major sites use coloured scrollbars? MSN? Yahoo? Lycos? Amazon? Ebay? Netscape? Google? No, they don't.
BODY {
width: 700px;
align: center;
}
(not tested)
Now, if you are using fully standards compliant xhtml inclusive of serving the correct Content-Type of application/xhtml+xml, the <html> tag is the outermost tag of the page and has taken the role of the <body> tag in traditional html. Thus, in xhmtl <body> is just another <div> and can be styled appropriately. I'm doing this on one of my own sites: [mozilla.mathiesen.info...] . And you had better visit it with a browser capable of handling 'Content-Type: application/xhtml+xml' or you'll just get a 'sorry'-page. The css can be accessed directly through this url: [mozilla.mathiesen.info...]
You should be able to centre your page using CSS on the BODY tag:
BODY {
width: 700px;
align: center;
}
(not tested)
I don't know why, but there's no such thing as an align property in CSS2. It may work in IE6 though (*shrug*). I've used the 'text-align: center' property with success before. text-align will center all contents of the box.