input width autosize
snippet in html

input width autosize

user2850

<input 	id="txt" 
		type="text" 
        onkeypress="this.style.width = (this.value.length + 1) + 'em';">