<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Vertical-align an element of unknown height</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <style type="text/css"> .outer { position:relative; display:table; height: 200px; width: 200px; vertical-align: middle; text-align: center; background:#ccc; float:left } .inner { width:100%; display:table-cell; vertical-align:bottom; position:relative; } p{ background:#aaa; } </style>
</head> <body> <div class="outer"><div class="inner"><p>this is a test. this is a test. this is a test. this is a test. this is a test. </p></div></div> </body> </html>