Solution 1 :

For the code to be HTML valid, you need to have td in a tr, if you intend to not put anything inside you can try something like below

<table class="collapse">
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
    </tr>
    <tr>
      <td colspan="4"></td>
    </tr>
</table>

Solution 2 :

Now the second box is filled with content

        *{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        .collapse{
            border-collapse: collapse;
        }
        tr{
            background: orange;
            border: solid;
            position: relative;
        }
        tr:before{
            content: "";
            min-height: 2rem;
            display: block;
        }
        td{
            padding: .5rem;
        }
<table class="collapse">
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
</table>

Solution 3 :

You can include <td> in all cells, even empty ones

*{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        .collapse{
            border-collapse: collapse;
        }
        tr{
            background: orange;
            border: solid;
        }
        tr:before{
            content: "";
            min-height: 2rem;
            display: block;
        }
        td{
            padding: .5rem;
        }
<table class="collapse">
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
    </tr>
    <tr>
      <td></td>
      <td></td>
      <td></td>
      <td></td>
    </tr>
</table>

Problem :

I tried to find a solution to my problem on the Internet and on this forum.

Question: why is the background-color not displayed for an empty row?

        *{
            padding: 0;
            margin: 0;
            box-sizing: border-box;
        }
        .collapse{
            border-collapse: collapse;
        }
        tr{
            background: orange;
            border: solid;
        }
        tr:before{
            content: "";
            min-height: 2rem;
            display: block;
        }
        td{
            padding: .5rem;
        }
<table class="collapse">
    <tr>
        <td>1</td>
        <td>2</td>
        <td>3</td>
        <td>4</td>
    </tr>
    <tr></tr>
</table>

Comments

Comment posted by Temani Afif

the browser don’t like the “display:block” you added inside the table

Comment posted by Vijay Kumawat

you need to put atleast one

in the row. you can use colspan to capture the whole row width. in your case it will be `

`

Comment posted by i like Cola

Hi Temani Afif! And which option will you like xD? It is desirable that it works min-height.

Comment posted by i like Cola

Hi Vijay Kumawat! Yes it’s works fine, and most likely I will do so.

By