Fixed <TR> height in table with strict doctype (Full Version)

All Forums >> [Web Development] >> General Web Development



Message


RowanReid -> Fixed <TR> height in table with strict doctype (4/8/2008 5:02:45)

Hi There,

I have included my code below. The table looks correct in Firefox 2 and Safari 3 but not IE7.

I am attempting to create a table that fills up the entire page with a fixed width row at the bottom. IE7 ignores the height I have set for the second row and makes both rows the same height.

Note that the Doctype tag is important here, if I remove it then the page looks correct, however it is my intention to ensure the browser runs in standards mode. As far as I am aware my code is correct.

Any help or advice would be appreciated.

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
	<style>
		html,body{
	   margin:0;
	   padding:0;
	   height:100%;
	   border:none;
		}
</style>
</head>
<table height="100%" cellpadding="0" cellspacing="0" border="1" width="100%">
	<tr>
		<td>
			Line 1
		</td>
	</tr>
	<tr style="height:10px;">
		<td>
			Line 2
		</td>
	</tr>
</table>
</html>




Tailslide -> RE: Fixed <TR> height in table with strict doctype (4/8/2008 6:39:38)

Hi

I'm not very good with tables but this seems to work:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
   <style type="text/css">
      html,body{
      margin:0;
      padding:0;
      height:100%;
      border:none;
      }
</style>
</head>
<body>
  <table border="1" cellpadding="0" cellspacing="0" style="width:100%;height:100%;">
    <tbody style="width:100%;height:90%;">
      <tr><td>Stuff goes here</td></tr>
      <tr style="height:10px;"><td>Stuff in the 10px high div</td></tr>
    </tbody>
 </table>
</body>
</html>


I should say however that if you're putting any text into the 10px high div then you're risking the layout breaking if someone increases the text-size. Generally if there's text there, you're better off with percentages.




RowanReid -> RE: Fixed <TR> height in table with strict doctype (4/9/2008 5:14:53)

Great, thanks for the help!




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.078125