Skip to: content, navigation

by Ian Lloyd

size (HTML attribute)

Browser support full matrix
IE5.5+ FF1+ Saf1.3+ Op9.2+
Full Full Full Full
Spec
Depr. Version
No HTML 2
size="number"

Example

The size 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.

Figure 1. Two inputs, the first with a size of 6, the second one with no size specified Two inputs, the first with a size of 6, the second one with no size specified

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

IE5.5Full
6.0Full
7.0Full
Firefox1.0Full
1.5Full
2.0Full
Safari1.3Full
2.0Full
3.0Full
Opera9.2Full
9.5Full

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.

Related Products

The Principles of Beautiful Web Design

Best Seller!

You don’t need to go to Art School to design great looking web sites!

Book Cover: The Principles of Beautiful Web Design

Download the FREE sample chapters