size (HTML attribute)
Example
Thesize
attribute set to "6" for a field that only requires 4
characters: <form> <label for="pin">Your 4-digit PIN:</label> <input type="password" name="pin" id="pin" maxlength="4" size="6" /> … </form>
Description
The size
attribute is used to set a width for a text or password input field, the
measurement of which relates to the number of characters that should be
visible, as shown in size#size__fig-input-size-6.
Given the presentational nature of this attribute, it is better to avoid using this attribute, instead using CSS to define widths using more precise measurements.
Value
A number relating to how many
characters wide, e.g. "5",
"10"
Compatibility
| IE | 5.5 | Full |
|---|---|---|
| 6.0 | Full | |
| 7.0 | Full | |
| Firefox | 1.0 | Full |
| 1.5 | Full | |
| 2.0 | Full | |
| Safari | 1.3 | Full |
| 2.0 | Full | |
| 3.0 | Full | |
| Opera | 9.2 | Full |
| 9.5 | Full |
Causes no compatibility issues. It has excellent support across all tested browsers.
User-contributed notes
Add a note
To post a note on this topic, please log in with your SitePoint username and password. If you don't have an account yet, you can create a new account for free.

