Click to See Complete Forum and Search --> : Nesting <TBODY> tags
djc11
06-12-2007, 10:37 PM
Is this possible : ) ?
It seems like there should be a way for me to nest my <TBODY> tags but the fact that it doesn't require and end tag ruins this. My goal is to have a tbody section that has one set of attributes nested in another tbody with a 2nd set of attributes. When the outside tbody's attributes are 'turned off' or changed I would like the nested tbodys to display their attributes.
Any ideas on how to implement this??:confused:
Major Payne
06-13-2007, 01:56 AM
The <tbody> tag does require a closing tag:
HTML TBODY TAG (http://www.w3schools.com/tags/tag_tbody.asp)
Ron
Mr Initial Man
06-13-2007, 08:37 AM
Why on earth do you want to nest <tbody> tags?
djc11
06-13-2007, 10:11 AM
I see that they use closing </TBODY> tags in the example on w3schools but it didn't work like that. I looked it up in the technical reports and it said that they were not necessary.
http://www.w3.org/TR/html401/
As far as why I am trying to use them I will explain and if you can think of a better solution I would love to try it. I've been banging my head against the wall for 2 weeks : )
I am displaying a table of info. This table is broken up into categories( e.g. A, B, C), sub categories(1, 2, 3), and sub-subcategories(a, b, c). When a user clicks on a category or subcategory head, I have a JS that collapses or expands the corresponding category. The reason I want them nested is because when they are expanded out i want them to be expanded to the same level they were when they were collapsed. Therefore all subsections and subsections must have their own attributes that can be remembered.
Any suggestions
According to the DTD, tbody can be nested although it does not pass the W3C validator.
Would not a nested list suffice? Else I might consider nesting tables.:(
djc11
06-13-2007, 10:58 AM
A list would not work because i have a whole row of data. And i tried nesting tables but the cols wouldn't line up as well. Especially when changing the size of the window. I may just have to forget the whole 'expanding to previous state' idea although that is kindof a major part of this site.
Mr Initial Man
06-13-2007, 08:04 PM
You COULD go for a table/list hybrid. But seriously, if you want to nest tables, you could use <colgroup> and <col> elements to set the columns to specific widths. Then you'll have an easier time lining them up
<table>
<colgroup>
<col width="#">
<col width="#">
....
</colgroup>
<thead>
....
djc11
06-14-2007, 10:16 AM
Thank you for all the ideas. Too bad they don't have tbody implemented differently. There could be a lot of uses for that.
Charles
04-03-2009, 10:56 AM
From the HTML 4.01 DTD:<!ELEMENT TBODY O O (TR)+ -- table body -->http://www.w3.org/TR/REC-html40/sgml/dtd.html
Which means the TBODY elemet has optional start and end tags and it can only contain one or more TR elements. The XHTML 1.0 DTD on the other hand:<!ELEMENT tbody (tr)+>http://www.w3.org/TR/xhtml1/dtds.html#a_dtd_XHTML-1.0-Strict
which differs from HTML in that both tags are required. The big difference is that in HTML the TBODY element is required so, like the HTML, HEAD and BODY elements, if you omit the tags the browser builds the element anyway. Since you can't omit tags in XHTML the TBODY element is optional and the browser will not create one. This has important implications for styles and scripts.