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!

validation error for <tfoot> 2

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I have a validation error
document type does not allow element "tfoot" here.

I'm a bit confused, it's in the right place , so i thought, can someone explain what's wrong please.


Thanks,
1DMF

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Well - as surprising as this may sound (and it certainly surprised me), you apparently need to put it BEFORE the TBODY. From
A TABLE may have one TFOOT, which must follow the optional THEAD and [!]precede[/!] the required TBODY.

Dan





Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
More from the W3C page
TFOOT must appear before TBODY within a TABLE definition so that user agents can render the foot before receiving all of the (potentially numerous) rows of data. The following summarizes which tags are required and which may be omitted:

* The TBODY start tag is always required except when the table contains only one table body and no table head or foot sections. The TBODY end tag may always be safely omitted.
* The start tags for THEAD and TFOOT are required when the table head and foot sections are present respectively, but the corresponding end tags may always be safely omitted.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
huh? , what? , you put the FOOTER, that displays at the BOTTOM of the table at the TOP of the table content?

what kind of crazy world do we live in?

[bomb]



"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
yeah , I saw that after posting, but if the footer is dynamic and the content relative to the content of the body, that blows that out the water doesn't it!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I've read the W3C's explanation, and it's still a silly idea to put the <tfoot> before the <tbody>. The browser has to read the whole table before it renders it in order to determine the column widths, so the argument that putting the <tfoot> at the end would cause problems doesn't hold water.

Putting the <tfoot> at the beginning clearly does cause problems, as there's a danger that it'll get rendered in the wrong place on old browsers (though it does work properly on IE6 for a change) or by screen readers. It's also a hassle if you're building the <table> dynamically and adding up data as you go to put into the footer.

I'd consider putting practicality above semantics in this case, and using an extra [tt]<tbody class="totals">[/tt] at the end of the table instead of a [tt]<tfoot>[/tt] at the beginning. Maybe they'll fix this one in HTML5.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
I'm glad i'm not the only one who thinks this.

If you were looping in a PERL program and printing direct to browser and you don't know the record count or some type of total until the loop eneded and x++ has your final value , how the hell are you going to output that before you've done the for loop?

It's imposible!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
It's imposible!
No, it's just a pain. You have to store the body into a variable so you can print it in the right place later:
Code:
print "<table>\n";
print "<thead><tr><th>Numbers</th></tr></thead>\n";

$total = 0;
$body = "<tbody>";
for ($i=0; $i < 10; $i++) {
   $n = int(rand(100));
   $total += $n;

   $body .= "<tr><td>$n</td></tr>\n";
}
$body .= "</tbody>\n";
print "<tfoot><tr><td>$total</td></tr></tfoot>\n";
print $body;
print "</table>\n";

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
err, Chris , I said if you were printing DIRECT to the browser, not storing the HTML and printing after the loop.

i have seen this method used loads in the perl forum, I use this method myself for one of my scripts, using...
Code:
# Set output for immediate display
local $| = 1;

because I need to track what is going on with the script 'real time'!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
I said if you were printing DIRECT to the browser, not storing the HTML and printing after the loop.
My example does print direct to the browser. All the printing it does (you see those five [tt]print[/tt] statements?) goes direct to the browser. I just defer the printing of what's in the loop until W3C are ready for it. It's a pain, but it's possible.

I need to track what is going on with the script 'real time'!
I think you'll struggle to do that over the web, browsers tend to want to read the whole table before they render any of it.

If you needed to insert print statements into the loop for debugging purposes, that would be OK. The HTML (probably) wouldn't be valid, but so what?

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
True Chris, and many examples tend to be print statements relative to the console having run the perl from the command line rather than a browser / web environment.

the problem was when i had shared hosting you couldn't get to the server to do a command line execution of anything, so had to do it in a web browser!

what i meant was many perlies would put the print statement within the loop outputting each line as the loop was passed over, if you then converted that code to output html to a browser, my point WOULD be valid.

But I myself now use a template module for code/html separation so you could in most cases do the footer before the actual bottom of the table, though I'm sure we could all code something to prove the point if we wanted to!

it certainly is one of those oddities though with the standards not 'appearing' to make logical , semantic sense, but us brits love to be cynical and find irony amusing, or is it just me! - lol

:)

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top