Can a textarea be sized to the content entered into it
<p>I have a textarea on a form that is populated with text from a database query ready for someone to edit.</p>

<p>I would like the textarea to show the whole content without the need to scroll, but don't want to put a large textarea when there is only a small amount of text.</p>

<p>Text can be from 5 to 300 characters.</p>

<p>I have seen a solution to this type of issue but only where the textarea grows onkeyup as shown below.</p>

<pre><code>&lt;script&gt;
function textAreaAdjust(o) {
o.style.height = "1px";
o.style.height = (25+o.scrollHeight)+"px";
}
&lt;/script&gt;
&lt;textarea onkeyup="textAreaAdjust(this)" style="overflow:hidden"&gt;&lt;/textarea&gt;
</code></pre>
