Search code examples
csscss-tables

How to define minimum height for tbody in CSS


I want to set a minimum height for tbody in CSS, even if no <tr><td></td></tr> in tbody, here is my code:

tbody{
  height: 500px;
  min-height:500px;
}

but it doesn't work. so what should I do to achieve this?


Solution

  • Why you want to do this?

    Min-height and height applies to block level elements and table isn't a block level element. Wrap your table inside a div (say div.table-wrap) and apply minimum height to that div.

    If you don't want table layout isn't important to you, then just add display:block to the CSS of tbody.