Forum Moderators: open

Message Too Old, No Replies

Complex (somewhat) table trouble

Missing a single <tr> but can't see it

         

neophyte

4:26 am on Jul 10, 2009 (gmt 0)

10+ Year Member



Hello All!

I don't do tables very often, but I've got a contract which - on one page - requires a table layout to display an assortment of (essentially) tabular-type data.

I've finally worked out the table structure and it looks correct but after a validation check (HTML TIDY) it reports that I've got a missing <tr>.

After staring at this for hours and tweaking one way or another, I can't find where in the world this extra <tr> would go... or, maybe, I've done the structure incorrectly which is why this error is coming up!

Table code posted here:

<table border="1">
<tr>
<td rowspan="6">image</td>
<tr><td>One</td><td>63</td><td>$100.00</td><td rowspan="6">comments</td></tr>
<tr><td>Two</td><td>63</td><td>$100.00</td></tr>
<tr><td>Three</td><td>63</td><td>$100.00</td></tr>
<tr><td>Four</td><td>63</td><td>$100.00</td></tr>
<tr><td>Five</td><td>63</td><td>$100.00</td></tr>
<td>caption</td><td>Six</td><td>63</td><td>$100.00</td>
</tr>
</table>

As per forum reqirements, DOCTYPE used is XHTML v1.0 Transitional.

Anyway, I need a fresh set of eyes on this if one of the good folks here wouldn't mind.

All assistance greatly appreciated!

Neophyte

StoutFiles

4:38 am on Jul 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Well first off, is below what you want? Image spans from row one to five, caption is in row 6, and comments spans all six rows.

image One 63 $100.00 comments
image Two 63 $100.00 comments
image Three 63 $100.00 comments
image Four 63 $100.00 comments
image Five 63 $100.00 comments
caption Six 63 $100.00 comments

neophyte

5:07 am on Jul 10, 2009 (gmt 0)

10+ Year Member



Hello StoutFiles -

Yes, the image is on the far left and spans row 1 to 5; Caption is directly below image in it's own td and is on the same "row" as as item 6. Comments span all rows on the right.

I don't know if that's understandable (kinda hard to explain in words) but if you load the code shown in my first post what you'll see is exactly what I'm after except for this mystery <tr> that HTML Tidy says i'm missing.

Again, I'm not sure if I've done this table structure correctly which may be the reason that I'm getting this error.

Appreciate your assistance.

Neophyte

StoutFiles

5:24 am on Jul 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



<tr><td>caption

neophyte

6:49 am on Jul 10, 2009 (gmt 0)

10+ Year Member



StoutFiles -

Wow, that did it. Fantastic: no more warning! But you know, I still don't understand...

Where's the closing </tr> for the open <tr> shown in bold below? It couldn't be the final </tr> before the closing table tag (could it?) because that file </tr> would (I think) be the closing tag for the "caption" row(?).

Really appreciate you helping me to solve this problem, but with the question above I'm obviously showing my table-based ignorance.

Neophyte

<table border="1">
<tr>
<td rowspan="6">image</td>
<tr><td>One</td><td>63</td><td>$100.00</td><td rowspan="6">comments</td></tr>
<tr><td>Two</td><td>63</td><td>$100.00</td></tr>
<tr><td>Three</td><td>63</td><td>$100.00</td></tr>
<tr><td>Four</td><td>63</td><td>$100.00</td></tr>
<tr><td>Five</td><td>63</td><td>$100.00</td></tr>
<tr><td>caption</td><td>Six</td><td>63</td><td>$100.00</td>
</tr>
</table>

SuzyUK

7:25 am on Jul 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



closing tags for <tr> elements are optional in HTML. The one you're looking for is IMPLIED before the next row opens (shown in red below). the last one is now closing that last row (blue bold) where the opening one was missing originally

<table border="1">
<tr><td rowspan="6">image</td></tr>
<tr><td>One</td><td>63</td><td>$100.00</td><td rowspan="6">comments</td></tr>
<tr><td>Two</td><td>63</td><td>$100.00</td></tr>
<tr><td>Three</td><td>63</td><td>$100.00</td></tr>
<tr><td>Four</td><td>63</td><td>$100.00</td></tr>
<tr><td>Five</td><td>63</td><td>$100.00</td></tr>
<tr><td>caption</td><td>Six</td><td>63</td><td>$100.00</td></tr>
</table>

neophyte

9:26 am on Jul 10, 2009 (gmt 0)

10+ Year Member



SusyUK

closing tags for <tr> elements are optional in HTML

Wow, I didn't know that ANYTHING in a table would be "implied" - I was under the (obviously mistaken) impression that if an open/closing tag was left out of any table element then the table would either break or - if it looked okay - wouldn't validate against TIDY.

Interesting. Lessons learned. Thanks for the insight.

Neophyte

swa66

12:16 pm on Jul 10, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



xhtml should not have any implied close tags at all.
Unfortunately browsers do try to salvage invalid xhtml as if it were html.

A validator such as the one at [validator.w3.org...] would point it out to you.

If you use xhtml you really have to make sure it's 100% valid.