Can a td be inside a td
Asked Answered
H

4

22

It may be a nonsense question, and I know we have to follow standards as much as possible. But can <td> be a direct child of another <td>, like this:

<td class="parent">
    <td class="child">
        <!-- Some info -->
    </td>
</td>

Or it's obligatory to create another <table> with a new <tr> before adding the <td>, which can become heavily populated with table tags and become clustered...

Hormone answered 20/9, 2011 at 12:3 Comment(7)
Putting an entire table in the cell isn't cluttered --- it's comprehensible. Don't write nonsense HTML to save typing.Mcbride
My recommendation: Stay away from nested tables!Davinadavine
They have their place --- some things are semantically best expressed as nested tables.Mcbride
@Mcbride - Like what? When was the last time you saw a nested table printed in a normal book (i.e. one not related in any way to HTML)?Damselfly
@Damselfly --- Conveniently enough, just two days ago, in a book giving specifications of early aircraft. Each row had an area for additional information, which was in a few cases tabular.Mcbride
Good thing the rest of us aren't browsing specs of early aircraft, the internet would be a more terrible place.Fustanella
On the other hand, this is clearly not a good use for it.Mcbride
M
33

not directly but you could place table inside td

<td class="parent">
   <table><tr>
    <td class="child">
        <!-- Some info -->
    </td>
   </tr></table>
</td>
Midtown answered 20/9, 2011 at 12:5 Comment(1)
You could also put a div inside a <td> and it would be slightly less heinous.Fustanella
N
4

No, <td> may not be a child of a <td>. A <td> may only be a child of a <tr>.

Nomanomad answered 20/9, 2011 at 12:4 Comment(0)
C
2

it's better to create a new table tag.

The example you give is not standard and the behavior can be different from a browser to another one

Chelonian answered 20/9, 2011 at 12:4 Comment(0)
H
0

The problem with not following standards like putting a <td> tag inside a <dt>, is that you cannot guarantee that the result is the same for all browsers, or that the next update of any browser will for example not simply ignore wrongly-used tags.

As a sidenote: we, as a developer comunity, have cried and shouted for Internet Explorer to finally start to take the standards seriously, so now let's not start making a mess ourselves!

Hilton answered 20/9, 2011 at 12:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.