Cells auto resizing

How do you set a class for all table widths and cell widths, so that all of the cells are a set number bigger than the width of the longest text, say, the width of the text, plus 2px on each side?

All table cells expand to fit their content (or the content of the cell in a column with the most amount of text), within the confines of the allowable width of the page or table. What you should do is add left and right padding to the cells in your css:

td {
   padding 0 2px;

So no preset width size on the tables or cells?

You could if you wanted to, but that wouldn’t give you the 2px space to the left and right of the content. You don’t know ahead of time what the content of the cell might be, or what font-size the user has decided to zoom to. So you can’t base the width of the table cells on their content.

So by not doing the widths, the cells will auto adjust?


Thanks. All sorted.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.