PDA

View Full Version : How do I set the height of a table in XHTML with CSS?


ze0nyx
02-17-2005, 07:13 AM
I have the following style sheet:table.main {
height: 100%;
}And the following document:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />
<link rel="StyleSheet" href="style.css" />
</head>
<body>
<table class="main">
<tr>
<td>
something
</td>
</tr>
</table>
</body>
</html>The code validates. But the table's height is very short, just to fit the text in. How do I fix this? I use Mozilla Firefox.

rmedek
02-17-2005, 07:14 PM
The table is expanding to 100% of its container, or the body. But the only thing in the body is "something," which means the table is only that high. If you want it to expand to 100% of the browser window, make the body and html do so as well...

html, body {
height: 100%;
margin: 0;
padding: 0;
}

table {
height: 100%;
}

Without the margins/padding you're going to get scrollbars, that's why that is in there... Hope this helps,

ze0nyx
02-17-2005, 07:34 PM
Thank you, rmedek, that sounds really logical. It worked out :thumbsup: .

rmedek
02-17-2005, 11:25 PM
No problem :)