Mike
Mike

Reputation: 2900

Content between rows in html table

I need to have a table where each row can have a child table or other content below that row.

Is there any valid way to do this?

Upvotes: 11

Views: 5420

Answers (4)

BalusC
BalusC

Reputation: 1109262

Add another <tr> after the current one with a colspan which spans all columns and then put another <td> with a <table> therein.

<tr>
    <td>col1</td>
    <td>col2</td>
    <td>col3</td>
</tr>
<tr>
    <td colspan="3">
        <table>...</table>
    </td>
</tr>
<tr>
    <td>col1</td>
    <td>col2</td>
    <td>col3</td>
</tr>

The new table will then appear between the rows.

Upvotes: 12

Guffa
Guffa

Reputation: 700592

You can't put anything inside a table between the rows, all content has to be inside the table cells.

You can add another row, and use colspan to make it contain a single cell that spans the width of the table, and put the content in that cell.

<table>
  <tr>
    <td></td>
    <td></td>
    <td></td>
  </tr>
  <tr>
    <td colspan="3"></td>
  </tr>
</table>

Upvotes: 6

NoBBy
NoBBy

Reputation: 497

There is no valid way. Only td-s and th-s are allowed in tr You can however put only 1 td in the row, and set it's colspan attribute to the number of columns you have in the table.

Upvotes: 1

alex
alex

Reputation: 490443

<table>
    <tbody>
        <tr>
            <td>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                 problem?
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>

Upvotes: 5

Related Questions