input要素の概要
input要素はWebページの閲覧ユーザーに入力コントロールを提供します。
これによりユーザーが入力した値を元にプログラムを処理するなどしてサイト運営者とユーザーの間で情報のやり取りができるようになります。
input要素は既定値でtext型の入力コントロールを表示しますが、type属性で入力型を指定することによって多くの入力コントロールを実装することができます。 次の項目で一覧表にまとめてありますので参考にしてください。
input要素に指定できるtype属性
type属性値 | 実機サンプル | サンプルコード |
---|---|---|
text (既定値) | <input type="text"> | |
button | <input type="button"> | |
checkbox | <input type="checkbox"> | |
color | <input type="color"> | |
date | <input type="date"> | |
datetime-local | <input type="datetime-local"> | |
<input type="email"> | ||
file | <input type="file"> | |
image |
送信機能なし: |
<input type="image" src="画像のURL"> このimage型はform要素に内包されるとsubmit機能を実装します。 |
month | <input type="month"> | |
number | <input type="number"> | |
password | <input type="password"> | |
radio |
<input type="radio" name="Radio">
|
|
range | <input type="range"> | |
reset | <input type="reset"> | |
search | <input type="search" | |
submit | <input type="submit"> | |
tel | <input type="tel"> | |
time | <input type="time"> | |
url | <input type="url"> | |
week | <input type="week"> |