Is there a way to automatically shrink text inside table cells? And if the text was already shrunk to the minimum-set size, the text will just wrap.
I don’t really understand the question but text will expand a table cell to a wide as the content needs to be or until the width of the table is constrained in some way.
If you want the table to expand until it reaches a certain dimension then use max-width to stop it getting any bigger.
e.g.
Not sure if that’s what you were asking though?
I think this is too much of an obvious answer to be what you are looking for, but:-
td { font-size: 0.8em; }
Will make text smaller in table cells.
Dynamic text sizing (AFAIK currently) can only be done by viewport width (vw
units), not container width, though I think there are scripts for that.
If the cell has expanded as much as it can, due to constraints on the table width or its container, the text will wrap in the cells. But one thing not enabled by default, that can help when space is tight, is enabling hyphenation in cells, so long words can wrap if they need to.
If text actually shrinking is required then something like this would work using vh and clamp.
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.