How to force min-height
and vertical-align:middle
to work for td
element or it's inner element?
To center both vertically and horizontally, use padding and text-align: center : I am vertically and horizontally centered.
Using the Line-Height Property In most cases, you can also center text vertically in a div by setting the line-height property with a value that is equal to the container element's height.
The height
on a td
element is the equivalent of min-height
, as a table cell will always stretch if required - but note that, especially in a complex table, that setting heights on table rows is a tricky, often impossible, process, browsers have a great deal of leeway in how they render tables and will often make a "judgement call"
td { height: 100px; vertical-align:middle; }
You can always put a div inside the td and put the css rules in the div...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With