Reply to Re: What if you don't have a thead/tbody/tfoot?

Your name:

Reply:


Posted by Harlan Messinger on 01/08/08 17:18

TonyV wrote:
> On Jan 6, 12:24 pm, Michael Fesser <neti...@gmx.de> wrote:
>> 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.

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>
</html>

> 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.
>
> On Jan 6, 12:24 pm, Michael Fesser <neti...@gmx.de> wrote:
>>> 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?
>
> 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.

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация