I'm having this markup:
<style> table { border:1px solid black; width:400px; height:300px; border-collapse:collapse; } table tbody { border:1px solid red; } table td { background:yellow; padding:10px; border-bottom:1px solid green; height:20px; } </style> <table> <tbody> <tr><td>test</td></tr> <tr><td>test</td></tr> </tbody> </table>
What I need is that the rows won't stretch in height. Is there a way to have a fixed row height?
The height of rows 'tr' in a table can be fixed very easily. This can be done by adding the height attribute in the tr tag. If the height is not specified, the height of the row changes according to the content. The height can be specified either in pixels, or percentage.
Change row height To set the row height to a specific measurement, click a cell in the row that you want to resize. On the Layout tab, in the Cell Size group, click in the Table Row Height box, and then specify the height you want. To use the ruler, select a cell in the table, and then drag the markers on the ruler.
CSS Table Row height. You can set Row Height through CSS line-height property it set to each tr. When you set this property, each row has heigh of 50 pixel.
To set the cell width and height, use the CSS style. The height and width attribute of the <td> cell isn't supported in HTML5. Use the CSS property width and height to set the width and height of the cell respectively. Just keep in mind, the usage of style attribute overrides any style set globally.
HTML Table row heights will typically change proportionally to the table height, if the table height is larger than the height of your rows. Since the table is forcing the height of your rows, you can remove the table height to resolve the issue. If this is not acceptable, you can also give the rows explicit height, and add a third row that will auto size to the remaining table height.
Another option in CSS2 is the Max-Height Property, although it may lead to strange behavior in a table.http://www.w3schools.com/cssref/pr_dim_max-height.asp
.
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