Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

height and valign of table

Status
Not open for further replies.

y2k1981

Programmer
Aug 2, 2002
773
IE
Hi All:

I've been validating my HTML recently, and I'm being told that the table tag does not have attributes height or valign. So I have two questions:

1. If I want my table to be 100% of the browser height, how do I do that?

2. If I want my table to be in the center of the page (a different table to the one that's 100% high) how do I do that?

Thanks all!!
 
i found that specifying hieghts in percentage doesnt seem to work for tables in Netscape browsers so you cant say height=100%. This is not so for IE

so you can say height=100% in IE

to centre a table put it in a container table that has 100% height and width
 
I know that it'll work, but it's not valid HTML according to the W3C
Code:
Line 29, character 330: 
... ="700" align="center" height="510" valign="top">
                                 ^
Error: there is no attribute HEIGHT for this element

So for the VALIGN, I just need to put the table in a div and set the valign for that instead?
Thanks!!
 
Code:
Errors and Warnings
Line 10, character 13: 
<div height=&quot;100%&quot; width=&quot;100%&quot; align=&quot;center&quot; valign=&quot;middl ...
            ^
Error: there is no attribute HEIGHT for this element (in this HTML version)

Line 10, character 26: 
<div height=&quot;100%&quot; width=&quot;100%&quot; align=&quot;center&quot; valign=&quot;middl ...
                         ^
Error: there is no attribute WIDTH for this element (in this HTML version)

Line 10, character 55: 
... &quot;100%&quot; align=&quot;center&quot; valign=&quot;middle&quot;>
                                 ^
Error: there is no attribute VALIGN for this element (in this HTML version)

Input
 1   <!DOCTYPE html PUBLIC &quot;-//W3C//DTD HTML 4.01 Transitional//EN&quot;
 2      &quot;[URL unfurl="true"]http://www.w3.org/TR/html4/loose.dtd&quot;>[/URL]
 3   <html>
 4     <head>
 5   
 6       <title></title>
 7   
 8     </head>
 9     <body>
10   <div height=&quot;100%&quot; width=&quot;100%&quot; align=&quot;center&quot; valign=&quot;middle&quot;>
11   <table width=&quot;80&quot;>
12   <tr><td>1</td><td>2</td></tr>
13   <tr><td>3</td><td>4</td></tr>
14   </table>
15   </div> 
16     </body>
17   </html>
the
Code:
div
tag doesn't have height or width attributes, and it doesn't allow valign either. So that wouldn't work, so what can I do so that it's W3C compliant?
 
If you look at the latest HTML 4.01 specifications at w3.org you find there are very few attributes that have not been deprecated, Only &quot;align&quot; remains for the ones you used in the <div> tag. This is to favour the use of CSS for layout.
So the way to go is use valid HTML and CSS, this will give much better cross browser rendering of your pages as you are not trying to use the browser proprietary attributes.

So for your div it would be;

div.classname {
height: 100%;
width: 100%;
vertical-align: top;
]
in your style sheet,
and
<div class=&quot;classname&quot; align=&quot;center&quot;>

</div>
in your document

don't forget you can validate your CSS as well.

Chris.



Indifference will be the downfall of mankind, but who cares?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top