What if you don't have a thead/tbody/tfoot?

T

TonyV

I've read that in XHTML 1.1, if you have a thead and tbody, you *must*
have a tfoot. Also, according to the specification, it looks like all
three *must* have at least one tr child element, with at least one th
or td child element in it. Here's the spec I'm reading:
http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_tablemodule

My question is pretty simple. What if you want a table with just a
thead and tbody section, but not with a tfoot section? I don't
understand why I *must* have a cell defined in up to two sections (in
this case, the tfoot section), cells which will be completely blank,
which I suppose means I'll have to use some CSS to make sure it's not
displayed, instead of just not having the section.

Is there a standard practice for what to do if you have a thead and
tbody but not a tfoot?
 
R

richard

I've read that in XHTML 1.1, if you have a thead and tbody, you *must*
have a tfoot. Also, according to the specification, it looks like all
three *must* have at least one tr child element, with at least one th
or td child element in it. Here's the spec I'm reading:
http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_tablemodule

My question is pretty simple. What if you want a table with just a
thead and tbody section, but not with a tfoot section? I don't
understand why I *must* have a cell defined in up to two sections (in
this case, the tfoot section), cells which will be completely blank,
which I suppose means I'll have to use some CSS to make sure it's not
displayed, instead of just not having the section.

Is there a standard practice for what to do if you have a thead and
tbody but not a tfoot?

Nothing says it has to have content. The rules are merely looking for
the tags.
<tfoot></tfoot>
If you have to have content, color it the same color as the background
and let it disappear.
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Sun, 06 Jan 2008 16:22:38
GMT TonyV scribed:
I've read that in XHTML 1.1, if you have a thead and tbody, you *must*
have a tfoot. Also, according to the specification, it looks like all
three *must* have at least one tr child element, with at least one th
or td child element in it. Here's the spec I'm reading:
http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_table
module

My question is pretty simple. What if you want a table with just a
thead and tbody section, but not with a tfoot section? I don't
understand why I *must* have a cell defined in up to two sections (in
this case, the tfoot section), cells which will be completely blank,
which I suppose means I'll have to use some CSS to make sure it's not
displayed, instead of just not having the section.

Is there a standard practice for what to do if you have a thead and
tbody but not a tfoot?

Yeah. I flip a tbird in the general direction of the w3c and eliminate the
extraneous crap from the page.
 
H

Harlan Messinger

TonyV said:
I've read that in XHTML 1.1, if you have a thead and tbody, you *must*
have a tfoot. Also, according to the specification, it looks like all
three *must* have at least one tr child element, with at least one th
or td child element in it. Here's the spec I'm reading:
http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_tablemodule

That's not how I'm reading it. The content model is:

caption?, ( col* | colgroup* ), (( thead?, tfoot?, tbody+ ) | ( tr+ ))

A question mark means "0 or 1", a plus sign means "1 or more". The only
"have to's" I see here is that if you have either a thead or a tfoot,
then you have to have at least one tbody, and if you have a tbody, then
every tr has to be in a thead or a tfoot or a tbody. Under no
circumstances is thead or tfoot required.
 
M

Michael Fesser

..oO(TonyV)
I've read that in XHTML 1.1, if you have a thead and tbody, you *must*
have a tfoot.

Where have you read that?
Also, according to the specification, it looks like all
three *must* have at least one tr child element, with at least one th
or td child element in it.

Correct. If they are present, they have to contain at least one row.

Micha
 
M

Michael Fesser

..oO(richard)
Nothing says it has to have content.

The DTD does (taken from XHTML 1.0):

<!ELEMENT thead (tr)+>
<!ELEMENT tfoot (tr)+>
<!ELEMENT tbody (tr)+>

At least one row is required in each row group.
And the 'tr' element must contain at least one cell:

The rules are merely looking for
the tags.
<tfoot></tfoot>

Invalid code.

Micha
 
B

Bergamot

TonyV said:
I've read that in XHTML 1.1, if you have a thead and tbody, you *must*
have a tfoot.

Is there a standard practice for what to do if you have a thead and
tbody but not a tfoot?

Yes, use HTML 4.01 instead of XHTML.
 
S

Sherman Pendley

TonyV said:
I've read that in XHTML 1.1, if you have a thead and tbody, you *must*
have a tfoot. Also, according to the specification, it looks like all
three *must* have at least one tr child element, with at least one th
or td child element in it. Here's the spec I'm reading:
http://www.w3.org/TR/xhtml-modularization/abstract_modules.html#s_tablemodule

My question is pretty simple. What if you want a table with just a
thead and tbody section, but not with a tfoot section?

Just don't include the tfoot.

In practice, it doesn't matter, since neither IE6 nor 7 has a real XHTML
parser anyway. If you serve it as text/html, they'll display it, but they
use their HTML parser to do it, treating the contents of your page as HTML
and ignoring the extra slashes and unknown elements as part of its error
handling.

It won't validate, but validation isn't very useful for something that
depends on IE's error correction to display properly in the first place.

sherm--
 
T

TonyV

The DTD does (taken from XHTML 1.0):

<!ELEMENT thead (tr)+>
<!ELEMENT tfoot (tr)+>
<!ELEMENT tbody (tr)+>

At least one row is required in each row group.
And the 'tr' element must contain at least one cell:

<!ELEMENT tr (th|td)+>

Michael is correct. If I include a thead and tbody without a tfoot,
the page doesn't validate. Also, if I include a tfoot without a tr,
or a tfoot with a tr without a td, the page doesn't validate. It
doesn't make sense to me that every table *must* have a tfoot, and I
was just kind of wondering if anyone knew the rationale behind it, and
if there was some standard way people created tables with all three
elements when one or two of them don't have anything to display. I'm
getting the vibe that there's not, other than people simply ignoring
the standard.

Where have you read that?

At the W3Schools site. It seems to be a very reliable reference that
I use all the time. Here's the specific link to the page:
http://www.w3schools.com/tags/tag_tbody.asp

In the tips and notes section, it says, "If you use the thead, tfoot
and tbody elements, you must use every element." I'm guessing that
they've parsed the DTD and this is how it's interpreted. The page not
validating seems to back it up.

In practice, it doesn't matter, since neither IE6 nor 7 has a real XHTML
parser anyway. If you serve it as text/html, they'll display it, but they
use their HTML parser to do it, treating the contents of your page as HTML
and ignoring the extra slashes and unknown elements as part of its error
handling.

It won't validate, but validation isn't very useful for something that
depends on IE's error correction to display properly in the first place.

This is true, the page will still render. However, I would really
like it to be coded according to the standards in place, even if I
don't agree with them. I've never been of the "work around the
standards if they don't suit your needs" philosophy; I think this is
one of the problems that has led to the numerous messes we're in now,
where companies or organizations just unilaterally decide that they're
going to do things their own way, and to hell with the standards.

Plus, there's the little matter that if the major browsers decide that
they will start enforcing all of these rules, something that does have
precedence, I'd like to make sure as much as possible that my code
still works without having to put in a bunch of if MyBrowser_v4 then
renderOneWay(); else if MyBrowser_v5 then renderAnother(); else
renderYetAnother(); kludges in.

Yeah. I flip a tbird in the general direction of the w3c and eliminate the
extraneous crap from the page.

As noted, I don't feel this is a practical long-term solution. In the
interest of my code working in future browsers that might enforce
adherence to the standards (which I wish they all did now), I won't be
"flipping a tbird in the general direction" of anyone.

Anyway, thanks for the answers, I guess I'll just include a tfoot
element with a tr and td that has no content. Empty tds don't render
anyway. I always thought that was weird, but I'm kind of glad now.
 
H

Harlan Messinger

TonyV said:
Michael is correct. If I include a thead and tbody without a tfoot,
the page doesn't validate.

If the page didn't validate it must have been for some other reason,
because I just passed the following through the W3C validator (with the
content type set to application/xhtml+xml) and it sailed through:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xml:lang="en" >
<head>
<title>Table Test</title>
</head>
<body>
<h1>Table Test</h1>
<table>
<thead>
<tr><th>Country</th><th>Capital</th></tr>
</thead>

<tbody>
<tr><td>Afghanistan</td><td>Kabul</td></tr>
<tr><td>Tajikistan</td><td>Dushanbe</td></tr>
<tr><td>Uzbekistan</td><td>Tashkent</td></tr>
</tbody>
</table>
</body>
Also, if I include a tfoot without a tr,
or a tfoot with a tr without a td, the page doesn't validate. It
doesn't make sense to me that every table *must* have a tfoot, and I
was just kind of wondering if anyone knew the rationale behind it, and
if there was some standard way people created tables with all three
elements when one or two of them don't have anything to display. I'm
getting the vibe that there's not, other than people simply ignoring
the standard.



At the W3Schools site. It seems to be a very reliable reference that
I use all the time. Here's the specific link to the page:
http://www.w3schools.com/tags/tag_tbody.asp

In the tips and notes section, it says, "If you use the thead, tfoot
and tbody elements, you must use every element."

They're wrong.
I'm guessing that
they've parsed the DTD and this is how it's interpreted. The page not
validating seems to back it up.

The DTD says the content model for a table is

caption?, ( col* | colgroup* ), (( thead?, tfoot?, tbody+ ) | ( tr+ ))

Parse this for yourself. It says that if you use either a thead *or* a
tfoot, then you must have at least one *tbody*. Under no circumstances
does it require either a thead or a tfoot.
 
M

Michael Fesser

..oO(TonyV)
If I include a thead and tbody without a tfoot,
the page doesn't validate.

I can't reproduce that. Can you post an example URL? I think there must
be another error in your markup. The following simple code snippet does
validate as HTML 4.01 Strict, XHTML 1.0 Strict and XHTML 1.1:

<table>
<thead>
<tr><th>test</th></tr>
</thead>
<tbody>
<tr><td>content</td></tr>
</tbody>
Also, if I include a tfoot without a tr,
or a tfoot with a tr without a td, the page doesn't validate.

This is correct.
At the W3Schools site. It seems to be a very reliable reference that
I use all the time. Here's the specific link to the page:
http://www.w3schools.com/tags/tag_tbody.asp

In the tips and notes section, it says, "If you use the thead, tfoot
and tbody elements, you must use every element." I'm guessing that
they've parsed the DTD and this is how it's interpreted. The page not
validating seems to back it up.

This statement is wrong or at least misleading. Given the DTD and the
actual validation results, I would say it this way:

By default all rows are put into an implicit 'tbody', so there's no need
to declare it. But if you use any of the row group elements 'tbody',
'thead' or 'tfoot', then every row must be contained in an explicitly
declared row group.

Micha
 
B

Bergamot

TonyV said:
In the
interest of my code working in future browsers

In that case it is imperative you dump XHTML, since it is not compatible
with even the current wave of browsers, let alone future ones. In case
you haven't heard, IE doesn't grok it at all. Stick with HTML 4.01
Strict if you want compatibility.
 
S

Sherman Pendley

TonyV said:
This is true, the page will still render. However, I would really
like it to be coded according to the standards in place, even if I
don't agree with them. I've never been of the "work around the
standards if they don't suit your needs" philosophy;

XHTML doesn't work at all without such workarounds; IE doesn't display it
at all unless it's served at text/html, and when it *is* served that way,
IE uses its HTML parser to display it.

So even if your XHTML page validates, you're still relying on IE's HTML
engine, which is not aware of XHTML at all, to ignore the extra slashes
and any other XML-isms that it sees as errors in HTML.

If you really wanted to avoid workarounds and hacks, you wouldn't be using
XHTML to begin with. Once you've started down that path, lying about the
content type and relying on IE's error handling to do something sensible
with markup it doesn't understand, it seems rather absurd to draw the line
at a missing tfoot element.
As noted, I don't feel this is a practical long-term solution.

You've already abandoned practicality in favor of buzzword compliance, by
using XHTML markup to begin with.

sherm--
 
T

TonyV

I can't reproduce that. Can you post an example URL? I think there must
be another error in your markup. The following simple code snippet does
validate as HTML 4.01 Strict, XHTML 1.0 Strict and XHTML 1.1:

<table>
<thead>
<tr><th>test</th></tr>
</thead>
<tbody>
<tr><td>content</td></tr>
</tbody>
</table>

Hmmm... You might be right, it could have been erroring out on some
other problem, because that does validate. If this is the case, then
this whole conversation is moot, except...

By default all rows are put into an implicit 'tbody', so there's no need
to declare it. But if you use any of the row group elements 'tbody',
'thead' or 'tfoot', then every row must be contained in an explicitly
declared row group.

I think you're right. I think that this is indeed the meaning of what
they said.

As for the other posts regarding the whole XHTML vs. HTML issue, I'm
not going to argue about it. I'm sorry if you disagree, but I think
that HTML is messy and inconsistent as a standard, and leaves too much
ambiguity up to browsers to figure out. I'm sticking with XHTML. I'm
also sorry if you have problems with the W3C, but the simple matter of
the fact is that they are the ones formally defining the standards.
If you don't want to use them, that's your prerogative, go for it.
This isn't a flame, it's my choice, and I choose to adhere to the
standards a closely as possible.

Thanks for the info Michael. When I get home, I definitely plan on
trying this stuff out. The site I'm working on is a private site so I
can't post to a URL right now, but based on what you ran through the
validator, it looks like I will be looking elsewhere to find out
what's wrong.
 
H

Harlan Messinger

TonyV said:
Hmmm... You might be right, it could have been erroring out on some
other problem, because that does validate. If this is the case, then
this whole conversation is moot, except...



I think you're right. I think that this is indeed the meaning of what
they said.

As for the other posts regarding the whole XHTML vs. HTML issue, I'm
not going to argue about it. I'm sorry if you disagree, but I think
that HTML is messy and inconsistent as a standard,

It is? How so? How is XHTML less messy and inconsistent?
and leaves too much
ambiguity up to browsers to figure out. I'm sticking with XHTML.

In what way does XHMTL leave browsers with less ambiguity to figure out
than HTML? As was already pointed out, some browsers aren't figuring out
XHTML *at all* except by pretending it's HTML with errors. Is that better?
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Tue, 08 Jan 2008 21:27:22
GMT Harlan Messinger scribed:
It is? How so? How is XHTML less messy and inconsistent?


In what way does XHMTL leave browsers with less ambiguity to figure
out than HTML? As was already pointed out, some browsers aren't
figuring out XHTML *at all* except by pretending it's HTML with
errors. Is that better?

Well, it works in human terms. Leaving the penis/penis-envy thang as a
separate issue, pretending women are men with errors makes getting along
with them considerably easier to swallow.
 
A

Adrienne Boswell

Gazing into my crystal ball I observed Neredbojias
Well, it works in human terms. Leaving the penis/penis-envy thang as a
separate issue, pretending women are men with errors makes getting along
with them considerably easier to swallow.

I believe you mean _men_ with errors. Sorry, couldn't help myself, and
you're right, it does make getting along with them easier to swallow (no
pun intended).
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Wed, 09 Jan 2008 15:37:58
GMT Adrienne Boswell scribed:
Gazing into my crystal ball I observed Neredbojias


I believe you mean _men_ with errors. Sorry, couldn't help myself,
and you're right, it does make getting along with them easier to
swallow (no pun intended).

<g>

Sure, men make plenty of mistakes. Reading the commentary on this very
newsgroup obviates the fact succinctly. The funny thing is that techie-
type men seem to make _more_ than the average man-mistakes whilst techie
women make _less_ than the average woman-mistakes. Go figure.

As a side note, my anecdotal denigration of the feminine mystique is
intended to be inciteful but not malicious. Various thoughts just
automatically pop into my head which I seem to have trouble ignoring (-the
thoughts, not my head) and simply must share with the world at large. I
find it strange, myself, and sometimes wonder if I'm not the unwitting
vessel of a higher life-form using me as a conduit for communication on a
plain not normally available to its nevertheless superior abilities. It's
a ponderable unknown and a lesser man could undoubtedly become quite
schizophrenic under such a pervadingly cosmological influence. Luckily, I
have the temperance, fortitude, and chutzpah to handle it.
 
D

dorayme

Neredbojias said:
Sure, men make plenty of mistakes. Reading the commentary on this very
newsgroup obviates the fact succinctly.

Do you know what "obviate" means? Do you use words because they
sort of just sound good to you?
The funny thing is that techie-
type men seem to make _more_ than the average man-mistakes whilst techie
women make _less_ than the average woman-mistakes. Go figure.

What is your silly reference for this silliness?
As a side note, my anecdotal denigration of the feminine mystique is
intended to be inciteful but not malicious. Various thoughts just
automatically pop into my head which I seem to have trouble ignoring (-the
thoughts, not my head) and simply must share with the world at large. I
find it strange, myself, and sometimes wonder if I'm not the unwitting
vessel of a higher life-form using me as a conduit for communication on a
plain not normally available to its nevertheless superior abilities. It's
a ponderable unknown and a lesser man could undoubtedly become quite
schizophrenic under such a pervadingly cosmological influence. Luckily, I
have the temperance, fortitude, and chutzpah to handle it.

What load of self serving, blind, codswallop!
 
M

Martin Leese

Neredbojias wrote:
....
I
find it strange, myself, and sometimes wonder if I'm not the unwitting
vessel of a higher life-form using me as a conduit for communication on a
plain not normally available to its nevertheless superior abilities.

Higher life-form?
 

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

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top