 <p>First get the text length by </p> <pre><code>var get = $("#value").val().length; </code></pre> <p>Then get the max size means width of button before this set a fixed width to button</p> <pre><code>maxScale = $("#value").width(); </code></pre> <p>then just reduce the font size by</p> <p>by comparing the both with if set the fontsize</p> <pre><code>if ( currentFontSize &lt; maxSize ) { currentFontSize += .1; $("button").css('font-size', fontSize + 'px'); </code></pre> <p>try this ...</p>