Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 336
Mike Avatar asked Mar 21 '11 14:03

Mike


People also ask

How do you put space between rows in HTML table?

Use the <tr> tag for each row. For the first row, use the <th> tag which defines a header cell in an HTML table. For the other rows, use the <td> tag which defines a standard data cell in an HTML table.

How do I split data in a table in HTML?

You have two options. Use an extra column in the header, and use <colspan> in your header to stretch a cell for two or more columns. Insert a <table> with 2 columns inside the td you want extra columns in.

What is tr TD and TH in HTML?

<tr>: The Table Row element. The <tr> HTML element defines a row of cells in a table. The row's cells can then be established using a mix of <td> (data cell) and <th> (header cell) elements.

How do I add a margin to a row in a table?

You cannot give margin to the table row. you can either give border-colapse and border spacing to the table or give border to table row and change its color to table background color.


4 Answers

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.

like image 120
BalusC Avatar answered Oct 14 '22 14:10

BalusC


<table>
    <tbody>
        <tr>
            <td>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                 problem?
                            </td>
                        </tr>
                    </tbody>
                </table>
            </td>
        </tr>
    </tbody>
</table>
like image 34
alex Avatar answered Oct 14 '22 12:10

alex


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>
like image 23
Guffa Avatar answered Oct 14 '22 14:10

Guffa


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.

like image 38
NoBBy Avatar answered Oct 14 '22 12:10

NoBBy