I have one html table and there are some rows inside the table. See the code below-
<table border="1">
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td></td>!-- Empty row -->
<td>Column 4</td>
</tr>
<tr>
<td>Column 1</td>
<td>Column 2</td>
<td>Column 3</td>
<td>Column 4</td>
</tr>
</table>
And it will looks like below in browser-
We can see in above html code that, there is an empty "td" in first row. And it’s showing blank when we are running the code in browser. I just want to move the data in each td to upwards td if there is no data in it.
So that, it should looks like below-
Is there any way to handle this by CSS changes ? If not then by any HTML changes. But I would like to avoid using any third party JS/CSS file to handle this.
2
Answers
I have read you don’t need to use javascript, You can try this css, hoping it will work —
Everything can happen in theory, imagination is good but different from reality.
I am assuming that the data is columnar: an item is not related to items on its left and right but to items above and below it. In that case you should change the HTML markup:
Another example, using grids: