dlg0351
04-27-2006, 11:51 PM
I am trying to recreate the following html code without using a table. I just want to use a div and css. I cannot get the text to align vertically in the middle. How can I do this? Any help is greatly appreciated.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<style>
<!--
div.red {
width: 150px;
height: 150px;
background-color: #FF0000;
text-align: center;
vertical-align: middle;
}
-->
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="150" height="150">
<tr>
<td bgcolor="#FF0000" valign="middle" align="center">Hello</td>
</tr>
</table>
<br /><br />
<div class="red">Hello</div>
</body>
</html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<style>
<!--
div.red {
width: 150px;
height: 150px;
background-color: #FF0000;
text-align: center;
vertical-align: middle;
}
-->
</style>
</head>
<body>
<table border="0" cellpadding="0" cellspacing="0" width="150" height="150">
<tr>
<td bgcolor="#FF0000" valign="middle" align="center">Hello</td>
</tr>
</table>
<br /><br />
<div class="red">Hello</div>
</body>
</html>