HTML CSS formatting: table row inherit content height

jpo picture jpo · Dec 26, 2012 · Viewed 21.3k times · Source

How can I format a table row to inherit the height of the content? I wish to have something like enter image description here

I have tried

table{
   table-layout:fixed;
   width:700px;
 }

but that does not work

Answer

ProfileTwist picture ProfileTwist · Dec 26, 2012

Tyipcally, a table will inherit the height of the content provided that the columns have a defined width using either percentage of the total table width or absolutel pixel "px" definitions. IN addition, be sure that the table rows do not have a specified height i.e. 'height: 30px'.

Code Solution:

table {
  width: 700px;
}
table tr td {
  width: 350px;
  height: auto;
}