HTML <入力>サイズ属性

❮HTML<input>タグ

幅50文字と4文字の2つの入力フィールドを持つHTMLフォーム:

<form action="/action_page.php">
  <label for="fname">First name:</label>
  <input type="text" id="fname" name="fname" size="50"><br><br>
  <label for="pin">PIN:</label>
  <input type="text" id="pin" name="pin" maxlength="4" size="4"><br><br>
  <input type="submit" value="Submit">
</form>

定義と使用法

このsize属性は、要素の表示幅を文字数で指定します<input>

注:このsize属性は、テキスト、検索、電話、URL、電子メール、およびパスワードの入力タイプで機能します。

ヒント:<input>要素で許可される最大文字数を指定するには、maxlength属性を使用します。


ブラウザのサポート

表の数字は、属性を完全にサポートする最初のブラウザーバージョンを示しています。

Attribute
size Yes Yes Yes Yes Yes

構文

<input size="number">

属性値

Value Description
number Specifies the width of an <input> element, in characters. Default value is 20

❮HTML<input>タグ