
-----------------------------------
Shaun Dreclin
Sat Jun 10, 2006 2:31 pm

Centering a page vertically
-----------------------------------
Well I know it should be simple, but I dont have any idea what the code is!

-----------------------------------
Shaun Dreclin
Sat Jun 10, 2006 2:32 pm


-----------------------------------
Hmm... Maybe its something like valign center.. *goes to try that*

-----------------------------------
wtd
Sat Jun 10, 2006 3:00 pm


-----------------------------------
There is no reliable way to do it.

-----------------------------------
rdrake
Sat Jun 10, 2006 3:10 pm


-----------------------------------
Like wtd said, there's no real way to do it easily and effectively.  You could use a bunch of  tags, but then that doesn't work at all resolutions.  You could use Javascript, but that too creates problems with many browsers.  You could insert a table which covers the entire screen and add a  in there, but that's far from proper technique.

Honestly there's no easy way to do this, and it's not recommended you use one of the above techniques to do it either.

-----------------------------------
[Gandalf]
Sat Jun 10, 2006 3:22 pm


-----------------------------------
Just use a table and valign that.  When your using plain HTML for anything more than an insignificant page it's almost impossible to write "proper" code.

^Advice from years of web development experience. :P

-----------------------------------
Amailer
Sat Jun 10, 2006 6:16 pm


-----------------------------------
won't 

body {
margin-right: auto;
margin-left: auto;
}

work?

-----------------------------------
md
Sat Jun 10, 2006 6:45 pm


-----------------------------------
That does centering left/right (in some browsers... forget about most versions of IE). Vertical centering is rather difficult though. Fortunately it's almost always pointless... so unless you have a really reason it's not worth hacking together.
