Advertisement
Home Open Editor ❯

HTML size Attribute

Example

<form action="action.php">
  <label for="uname">User name:</label>
  <input type="text" id="uname" name="uname" size="10"><br><br>
  <label for="pin">PIN:</label>
  <input type="password" id="pin" name="pin" maxlength="4" size="4"><br><br>
  <input type="submit" value="Submit">
</form>

Try this code ❯

Meaning

The size attribute specifies the visible dimension, in characters, of a text form control.

This differs from the maximum length of content, which can be entered in a form control set by the maxlength attribute.


Standard Syntax

<element size="number">


Applies to:

The size attribute can be used on the following element:

Element Attribute
<input> size
<select> size

Advertisement

Attribute Values

Value Description
number Specifies the size of the input field. (Default value is 20.)

More Examples

Example

<label for="lang">Choose your option:</label>

<select name="language" id="lang" size="2">
  <option value="HTML">HTML</option>
  <option value="CSS">CSS</option>
  <option value="JavaScript">JavaScript</option>
</select>

Try this code ❯

Home Open Editor ❯
Advertisement