TD is a block element,
but displays like inline,say,several TDs within a TR display in the same line,
why?
TD is a block element,
but displays like inline,say,several TDs within a TR display in the same line,
why?
TD's are actually not technically "block" elements. Have a look at the CSS display property. Cells are technically of type "table-cell" and they are a special case.
There is also another type of display called "inline-block" which can be useful.
If you want a <td>
to display as a "block," simply add another <tr>
below the current <tr>
. This will effectively make the <td>
act like a block-level element.
Let's say you have a table like this:
<table>
<tr>
<td>Table cell A</td>
<td>Table cell B</td>
</tr>
</table>
And you want "Table cell B" to act like a "block." You could do this:
<table>
<tr>
<td>Table cell A</td>
</tr>
<tr>
<td>Table cell B</td>
</tr>
</table>
This moves Table cell B below Table cell A.