Input Email size Attribute

Definition and Usage

size Attribute to set or return the value of the size attribute of the email field.

The HTML size attribute specifies the width of the email field (in number of characters), with a default value of 20.

Tip:To set or return the maximum number of allowed characters in the password field, use maxLength attribute.

See also:

HTML Reference Manual:HTML <input> size 属性

Example

Example 1

Set the email field as a required part of the form submission:

document.getElementById("myEmail").size = "50";

Try it yourself

Example 2

Display the width of the email field (in number of characters):

var x = document.getElementById("myEmail").size;

Try it yourself

Syntax

Return size attribute:

emailObject.size

Set size attribute:

emailObject.size = number

属性值

描述
number 规定电子邮件字段的字符数计的宽度。默认值为 20。

技术细节

返回值: 数值,表示电子邮件字段的宽度,以字符数为单位。

浏览器支持

表中的数字注明了首个完全支持该属性的浏览器版本。

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 10.0 支持 支持 支持