HTML <input> 标签
实例
以下 HTML 表单中的两个输入字段的宽度分别为 35 个字符和 4 个字符:
<form
action="demo_form.html">
Email: <input type="text" name="email" size="35"><br>
PIN: <input type="text" name="pin" maxlength="4" size="4"><br>
<input type="submit" value="提交">
</form>
浏览器支持





所有主流浏览器都支持 size 属性。
定义和用法
size 属性规定以字符数计的 <input> 元素的可见宽度。
注意:size 属性适用于下面的 input 类型:text、search、tel、url、email 和 password。
提示:如需规定 <input> 元素中允许的最大字符数,请使用 maxlength 属性。
HTML 4.01 与 HTML5之间的差异
无。
语法
属性值
值 |
描述 |
number |
规定以字符数计的 <input> 元素的宽度。默认值是 20。 |
HTML <input> 标签其他扩展