display:table;
display:table-cell;
vertical-align:middle;
  • Everything in this table cell div is centred
  • It can dynamically change to any height based on content (try by changing your browser font size)
  • Doesn’t get cut off when there isn't enough room
  • Doesn’t work in Internet Explorer
  • Uses 2 extra divs
Any object, with relative positioning

positoin:absolute; top:50%; height:240px; margin-top:(negative half the height);

float:left;
height:50%;
margin-bottom:-120px;

position:relative; clear:left; height:240px;

Any object, with relative positioning

top:0; bottom:0; left:0; right:0;
position:absolute; margin:auto;
height:something; width:something;

Single Line

line-height:10em; height:10em;

By Douglas Heriot 2008

For NetTuts.com