CSS: Set font to a size so the text would occupy whole container [duplicate]
This question already has answers here : Closed 8 years ago . Possible Duplicate: resize font to fit in a div (on one line) For a small flashcard maker app I need to set the correct font size so text would fill all the available width of a fixed-size container; like the text in the four boxes in this picture: A solution using PHP GD has been provided to this question . Is there a client side solution with css or javascript to this problem? it's not brute force ;) HTML: <span id="txt">Lorem</span> <div id="card"></div> CSS: #card { width: 150px; height: 50px; border: 1px solid black } #txt {