<input size=1> <script> document.getElementsByTagName("input")[0].onkeyup = function () { this.size = this.value.length || 1; }; </script>