HTML <input>プレースホルダー属性
例
プレースホルダーテキストを含む電話入力フィールド:
<form action="/action_page.php">
<label for="phone">Enter a phone number:</label><br><br>
<input type="tel" id="phone" name="phone" placeholder="123-45-678"
pattern="[0-9]{3}-[0-9]{2}-[0-9]{3}"><br><br>
<small>Format:
123-45-678</small><br><br>
<input type="submit">
</form>
定義と使用法
このplaceholder
属性は、入力フィールドの期待値を説明する短いヒントを指定します(たとえば、サンプル値または期待される形式の簡単な説明)。
ユーザーが値を入力する前に、入力フィールドに短いヒントが表示されます。
注:このplaceholder
属性は、テキスト、検索、URL、電話、電子メール、およびパスワードの入力タイプで機能します。
ブラウザのサポート
表の数字は、属性を完全にサポートする最初のブラウザーバージョンを示しています。
Attribute | |||||
---|---|---|---|---|---|
placeholder | 10.0 | 10.0 | 4.0 | 5.0 | 11.0 |
構文
<input placeholder="text">
属性値
Value | Description |
---|---|
text | Specifies a short hint that describes the expected value of the input field |
❮HTML<input>タグ