Forum Moderators: open

Message Too Old, No Replies

Centering table inside table

         

ktalai

12:23 pm on Aug 25, 2006 (gmt 0)

10+ Year Member



Hello,
The following code shows the inner table centered inside the outer table however it doesn't center in Firefox. Which browser is right according w3c and if Firefox shows the correct rendering, is there anyway to center tables inside tables using Firefox?

Thanks a bunch in advance,
Kamran

<table border="1" width="100%" >
<tr>
<td width="100%" align="center" style="text-align:center">
<table id="table2" border="1" width="100">
<tr>
<td>Table</td>
</tr>
</table>

birdbrain

1:02 pm on Aug 25, 2006 (gmt 0)



Hi there ktalai,

and a warm welcome to these forums. :)

As Firefox and Opera are compliant browsers, it is safe to assume that IE is rendering the code incorrectly. ;)
Also note that the code that you supplied is missing some closing tags. :o
Have a look at this code, it may give you some ideas...


<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<style type="text/css">
<!--
html,body {
height:100%;
margin:0;
padding:0;
}
#table1 {
width:100%;
height:100%;
border:2px solid #99f;
}
#table1 td{
border:1px solid #00f;
}
#table2 {
margin:auto;
border:2px solid #99f;
}
#table2 td{
width:100px;
text-align:center;
border:1px solid #00f;
}
-->
</style>

</head>
<body>

<table id="table1"><tr><td>

<table id="table2"><tr>
<td>Table</td>
</tr></table>

</td></tr></table>

</body>
</html>

birdbrain

ktalai

7:08 pm on Aug 25, 2006 (gmt 0)

10+ Year Member



Bird brain? If you are bird brain then I am a single molecule brain. Thank you very much. I am learning how ignorant I am about the standards. With the code as you specified Firefox works with or without the <!DOCTYPE tag:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">

But IE needs this tag or it doesn't center horizontally

Do you or any other kind folks on this forum happen to know how to force visual studio express to include this tag in the html file that is sent over to the browser.

Thanks a whole bunch
Kamran