HTML input size 屬性
實例
以下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>
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之間的差異
無。
語法
<input size="number">
屬性值
值 | 描述 |
---|---|
number | 规定以字符数计的 <input> 元素的宽度。默认值是 20。 |
HTML <input>標籤