Auto-size dynamic text to fill fixed size container

I need to display user entered text into a fixed size div. What i want is for the font size to be automatically adjusted so that the text fills the box as much as possible.

So – If the div is 400px x 300px. If someone enters ABC then it’s really big font. If they enter a paragraph, then it would be a tiny font.

I’d probably want to start with a maximum font size – maybe 32px, and while the text is too big to fit the container, shrink the font size until it fits.

21 Answers
21

Leave a Comment