placeholder 属性は、入力フィールド/テキストエリアの期待値を説明する短いヒントを指定します。
短いヒントは、ユーザが値を入力する前に、フィールドに表示されます。
placeholder 属性は、以下の要素で使用することができます:
要素 | 属性 |
---|---|
<input> | placeholder |
<textarea> | placeholder |
プレースホルダテキストを持つ 2 つの入力フィールド:
<form action="demo_form.html">
<input type="text" name="fname" placeholder="First
name"><br>
<input type="text" name="lname" placeholder="Last
name"><br>
<input type="submit" value="Submit">
</form>
Try it Yourself ❯
プレースホルダテキストを持つテキストエリア:
<textarea placeholder="Describe yourself here..."></textarea>
Try it Yourself ❯
placeholder
属性は、要素ごとに以下のブラウザがサポートしています。
要素 | |||||
---|---|---|---|---|---|
input | 10.0 | 10.0 | 4.0 | 5.0 | 11.0 |
textarea | Yes | 10.0 | 4.0 | 5.0 | 11.5 |