We would like to know how to vertical align a table inside a div.
<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#background {
width: 400px;
height: 400px;
border: 1px solid black;
}<!--from w w w . j a v a2s . co m-->
table {
width: 100px;
height: 100px;
position: relative;
left: 50%;
top: 50%;
margin-left: -50px;
margin-top: -50px;
}
</style>
</head>
<body>
<div id="background">
<table border="1">
<tr>
<td>Foo</td>
<td>Foo</td>
</tr>
</table>
</div>
</body>
</html>
The code above is rendered as follows: