<! Doctype html>
<Html>
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<Meta http-equiv = "cache-control" content = "no-cache"/>
<Style>
<! --
Html, body {
Height: 100%;
Margin: 0;
Padding: 0;
}
Body {
Position: relative;
}
# Div {
Background: blue;
Color: # fff;
Position: absolute;
Top: 50%;
Left: 50%;
Height: 240px;
Width: 240px;
Margin:-120px 0 0-120px;
}
--> </Style>
</Head>
<Body>
<Div id = "div">
I'm Mr. Middle.
</Div>
</Body>
</Html>
Method 2
<! Doctype html>
<Html>
<Head>
<Meta http-equiv = "content-type" content = "text/html; charset = utf-8"/>
<Meta http-equiv = "cache-control" content = "no-cache"/>
<Style>
<! --
Html, body {
Height: 100%;
Margin: 0 auto;
Padding: 0;
}
Body {
Position: relative;
Display: table;
}
# Wrapper {
Display: table-cell;
Vertical-align: middle;
Text-align: middle;
}
# Div {
Background: blue;
Color: # fff;
}
* Html # wrapper, * + html # wrapper {
Position: absolute;
Top: 50%;
}
* Html # div, * + html # div {
Position: relative;
Top:-50%;
}
--> </Style>
</Head>
<Body>
<Div id = "wrapper">
<Div id = "div">
I'm Mr. Middle.
I'm Mr. Middle.
I'm Mr. Middle.
</Div>
</Div>
</Body>
</Html>