English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

HTML Reference Manual

Complete List of HTML Tags

HTML: <input> size attribute

The HTML <input> size attribute specifies the visible width of the <input> element (in characters), the size attribute is applicable to the following input types: text, search, tel, url, email, and password.

 HTML <input> tag

Online Example

An HTML form that includes two input fields, with widths of11and6Number of characters:

<!DOCTYPE html>
<html>
<head>
<title>HTML: <input> size attribute - Basic Tutorial Website(oldtoolbag.com)</title>
<body>
<form action="action_page.php">
  Phone number: <input type="text" name="email" size="11><br>
  Postal code <input type="text" name="code" maxlength="6" size="6><br>
  <input type="submit" value="Submit">
</form>
</html>
Test it out ‹/›

Browser Compatibility

IEFirefoxOperaChromeSafari

All major browsers support the size attribute.

Definition and Usage

The size attribute specifies the visible width of the <input> element (in characters).

Note:The size attribute applies to the following input types: text, search, tel, url, email, and password.

Tip:To specify the maximum number of characters allowed in the <input> element, use maxlength properties.

HTML 4.01 with HTML5differences

None.

Syntax

<input size="number">

Attribute Value

ValueDescription
numberSpecifies the width of the <input> element in terms of character count. The default value is 20.
 HTML <input> tag