size attribute is used to set the width of a text,
password or file input field. The length of these fields is determined by
the number of characters that should be visible, as Figure 1 shows.
For all other
input types, the
size refers to the width of the control in pixels.
Given the presentational nature of this attribute, it’s usually best
avoided. Instead, use CSS to define field widths using more precise
measurements, with the exception of a file input where CSS control over
the input’s appearance is severely limited (for very valid security
reasons) and the
size attribute is your only real
sizeattribute is set to
"6"for a password field that only requires four characters:
<form> <label for="pin">Your 4-digit PIN:</label> <input type="password" name="pin" id="pin" maxlength="4" size="6"/> ⋮ </form>
This attribute takes a number that
reflects the field’s width in characters—for example,
"10", and so
It causes no compatibility issues, and has excellent support across all tested browsers.