CSS: Position text in the middle of the page

snarkyazoid picture snarkyazoid · Oct 30, 2011 · Viewed 100.7k times · Source

I would like to position a <h1> in the middle of any user's page. I have been searching the internet and they all position it in the incorrect place. Thank you!

UPDATE: I mean vertical and horizontal! In the exact middle!
ALSO: There is nothing else on the page.

Answer

Ry- picture Ry- · Oct 30, 2011

Try this CSS:

h1 {
    left: 0;
    line-height: 200px;
    margin-top: -100px;
    position: absolute;
    text-align: center;
    top: 50%;
    width: 100%;
}

jsFiddle: http://jsfiddle.net/wprw3/