Take the 2-minute tour ×
<input name="Username" type="text" id="Username" width="auto" height="auto">

I want to know the value of auto... the Integet value behind this.

share|improve this question
add comment

4 Answers

up vote 2 down vote accepted

Use javascript:


share|improve this answer
add comment

There is no integer value behind it, it is a validity error. Input elements do not have a width (or a height) attribute, and no width attribute in HTML takes auto as a value.

The attributes will be ignored and the size of that element will be determined by the usual pattern of user stylesheet falling back to author stylesheet falling back to browser stylesheet.

share|improve this answer
add comment

alert(document.getElementById('Username').offsetWidth); //chrome and others
alert(document.all.Username.offsetWidth); // for ie and chrome
share|improve this answer
Internet Explorer has happily supported getElementById for a very long time. You only need to go near document.all if you need to support Internet Explorer 4 (which you don't). There is no reason for document.all to appear in code written today. –  Quentin Jun 22 '11 at 12:51
thanks i put that because i'm used to, but it's true that the getElementById is now supported ;) –  darkylmnx Jun 22 '11 at 12:54
add comment

"Auto" is the default value of a text box height.

If you don't want to specify width or height of the textbox, HTML accepts auto as a value.

Hope this helps.

share|improve this answer
add comment

Your Answer


