Skip to main content
removed deprecated tag [table] - https://meta.stackexchange.com/questions/198024/can-we-start-cleaning-up-table-tag-and-burninate-it-asap
Link
added 8 characters in body
Source Link
DarkLeafyGreen
  • 70.6k
  • 136
  • 394
  • 617

I want a table to have fixed width but dynamic height because content may be of various length. Here is an example:

alt text

I have fixed width but the content is overlapping. What I am doing wrong? Here is my code:

<table width="60%" align='center' cellpadding='2' cellspacing='2' border='2' style='table-layout:fixed'> <thead> <tr> <th>#</th> </tr> </thead> <tbody> ... </tbody> </table> 

And my css:

table{ font-size:12px; }

table{ font-size:12px; } table td{ padding:5px; height:auto; background:#f6f6f6; } table thead tr th{ background:#d7dbe2; } 

Any ideas how to make the height dynamic?

I want a table to have fixed width but dynamic height because content may be of various length. Here is an example:

alt text

I have fixed width but the content is overlapping. What I am doing wrong? Here is my code:

<table width="60%" align='center' cellpadding='2' cellspacing='2' border='2' style='table-layout:fixed'> <thead> <tr> <th>#</th> </tr> </thead> <tbody> ... </tbody> </table> 

And my css:

table{ font-size:12px; }

table td{ padding:5px; height:auto; background:#f6f6f6; } table thead tr th{ background:#d7dbe2; } 

Any ideas how to make the height dynamic?

I want a table to have fixed width but dynamic height because content may be of various length. Here is an example:

alt text

I have fixed width but the content is overlapping. What I am doing wrong? Here is my code:

<table width="60%" align='center' cellpadding='2' cellspacing='2' border='2' style='table-layout:fixed'> <thead> <tr> <th>#</th> </tr> </thead> <tbody> ... </tbody> </table> 

And my css:

table{ font-size:12px; } table td{ padding:5px; height:auto; background:#f6f6f6; } table thead tr th{ background:#d7dbe2; } 

Any ideas how to make the height dynamic?

Source Link
DarkLeafyGreen
  • 70.6k
  • 136
  • 394
  • 617

Create HTML table with fixed width columns with CSS

I want a table to have fixed width but dynamic height because content may be of various length. Here is an example:

alt text

I have fixed width but the content is overlapping. What I am doing wrong? Here is my code:

<table width="60%" align='center' cellpadding='2' cellspacing='2' border='2' style='table-layout:fixed'> <thead> <tr> <th>#</th> </tr> </thead> <tbody> ... </tbody> </table> 

And my css:

table{ font-size:12px; }

table td{ padding:5px; height:auto; background:#f6f6f6; } table thead tr th{ background:#d7dbe2; } 

Any ideas how to make the height dynamic?