thank you sam - the table man

W

WindAndWaves

Hi gurus

I often work with tables and I found that I am confused on where I should be
placing the following elements:

width
height
valign

could I put all of them in the TD tag and leave the TABLE and TR tag blank?

Thank you

Nicolaas
 
W

Webcastmaker

I often work with tables and I found that I am confused on where I should be
placing the following elements:
width
height
valign
could I put all of them in the TD tag and leave the TABLE and TR tag blank?

Well ignoring the naming issues, the answer is none of the above.
Use CSS
 
W

WindAndWaves

Dear WebcastMaker

There are two reasons that I put it in the html:

1. browsers that do not support css can still read it and make sense of
things (or in case for some reason the css does not load properly).

2. it is easier to edit the pages if you know in the html how big the cells
are and the like, it is this ease of editing that I use more than anything
(my sites are completely database driven - but someone still has to write
the templates).

Thank you. still keen to find out the answer.
 
W

WindAndWaves

so how do you specify a table to have a certain height????

can you use <TD HEIGHT=20>? or <TR HEIGHT=20>???
 
T

The Doormouse

WindAndWaves said:
so how do you specify a table to have a certain height????

can you use <TD HEIGHT=20>? or <TR HEIGHT=20>???

No, you don't specify it. At best, you could put a spacer GIF in there
somewhere. Or, use CSS to specify it.

The Doormouse
 
W

WindAndWaves

Sorry to bother Doormouse, but why don't you specify it, is there any
specific reason for that?
 
R

rf

[crosspost removed, not on my server]

WindAndWaves wrote

Please quote a little of the post to which you are replying. It makes it far
easier to follow the conversation.
Sorry to bother Doormouse, but why don't you specify it, is there any
specific reason for that?

Width and Height for table cells has been deprecated in favour of CSS. Width
and height is a presentational issue and presentational issues should be
handled with CSS.

Since these attributes have been deprecated they are not supported by the
strict DTD so your page will not validate to strict if you use them.

http://www.w3.org/TR/html4/struct/tables.html#adef-height-TH
http://www.w3.org/TR/html4/struct/tables.html#adef-width-TH
and
http://www.w3.org/TR/REC-CSS2/tables.html
 
W

Webcastmaker

There are two reasons that I put it in the html:
Both reasons are invalid.
Thank you. still keen to find out the answer.
You have your answer. Notice how everyone gave your the same answer?
Use CSS. You just don't like the answer.
 
W

WindAndWaves

Dear webcastmaker,

I hope you are enjoying your day. I am actually changing my site. Thank
you for your answer.
 
L

Leif K-Brooks

WindAndWaves said:
I often work with tables and I found that I am confused on where I should be
placing the following elements:

width
height
valign

Those are attributes, not elements. More importantly, though, you don't
want to be using those particular attribures. They deal with
presentation, something which HTML was never meant to do.

On a guess, you're using a table to lay out your page. If so, read
<http://www.allmyfaqs.com/faq.pl?Tableless_layouts>.
 
W

Webcastmaker

Those are attributes, not elements. More importantly, though, you don't
want to be using those particular attribures. They deal with
presentation, something which HTML was never meant to do.
On a guess, you're using a table to lay out your page. If so, read
<http://www.allmyfaqs.com/faq.pl?Tableless_layouts>.

Your just blowing smoke here. This guy has no intentions of
listening to anyone until they say "why yes, put those "elements"
here....
 
T

The Doormouse

WindAndWaves said:
Sorry to bother Doormouse, but why don't you specify it, is there any
specific reason for that?

Height is controlled by content (or by CSS). Content is always paramount.
Also, the height tag has never been valid HTML, AFAIK. The width tag,
however, I do use from time to time and will validate as HTML 4.01
Transitional.

If you absolutely must have a certain height, you can use a spacer or
CSS. A spacer will always work - regardless of whether your CSS works or
not. CSS gives better control and can hold comments, too.

Spacer GIF:
* make transparent in several convenient sizes (5, 10, 25 pixels for
example).
* can be any width/height that you want.
* many of the same benefits as CSS, plus ultimately very backwards-
compatible

CSS:
* much greater control possible
* comments possible, easy maintenance
* one-stop shopping for presentational control

The Doormouse
 
T

The Doormouse

Webcastmaker said:
You have your answer. Notice how everyone gave your the same answer?
Use CSS. You just don't like the answer.

A spacer works too. :)

The Doormouse
 
A

Andy Dingley

I often work with tables and I found that I am confused on where I should be
placing the following elements:

width
height
valign

could I put all of them in the TD tag and leave the TABLE and TR tag blank?

It's time you learned to read a DTD
http://www.w3.org/TR/html4/sgml/dtd.html

or the version with notes
http://www.w3.org/TR/html4/struct/tables.html#edef-TABLE

The great thing about HTML (and pretty much all net protocols) is that
_you_ can read the real protocol definitions for yourself and for
free. Don't get it second-hand from some hack journalist's book, read
the genuine article.


Reading these, you'll find that only the <td> has width and height.,
and <tr> doesn't. <table> also has width, but that's the width of the
whole table, not a cell.

The align (horizontal) and valign attributes apply to both <tr> and
<td>, with scope applied much as you might expect.

There's also the <colgroup> and <col> elements, which are much
under-used. I've seen people nest tables to do things that were easily
and more simply done with <colgroup>, just through sheer ignorance of
their existence. Commonly you'll want to set alignment for a column
of <td>s (sometimes a width too) and using a <col> avoids the need to
repeat this on every <td>


As for CSS, then there is no reason why you _must_ do this. No reason
at all. It's not "better" to do this in any way - only if it gives you
some concrete advantage as a result can you talk about there being "a
benefit of CSS".

CSS is also a damn nuisance unless you understand it. Tag soup can be
a mess, but so is half-hearted CSS that's used by people who don't
know more than how to replace <font> with it.

The most obvious CSS benefit for tables is that it gives you more
dimension units to choose from. Rather than just pixel or percentage
units (or auto-size), you can also use ems or cm etc. In a world of
varying screen sizes, using ems instead of pixels can be a valuable
usability improvement.

If you have many table cells to worry about, using the class attribute
and some CSS can save you a lot of repeated width or alignment
settings. Otherwise you can use in-lined CSS with the style
attribute. Don't forget <col> either - it still works with CSS.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,048
Latest member
verona

Latest Threads

Top