HTML 属性: for
for
属性は <label>
と <output>
で利用できる属性です。 <label>
要素上で使用された場合、このラベルが説明するフォーム要素を示します。 <output>
要素上で使用された場合、その出力欄で使用される値を表す要素間の関係を明示的に示すことができます。
試してみましょう
使用方法
<label>
の属性として使用された場合、 for
属性はそのラベルが関連するフォーム要素の id
値を保持します。
html
<label for="username">Your name</label> <input type="text" id="username" />
<output>
の属性として使用された場合、 for
属性はその出力を作成するために使用される要素の id
値を、空白で区切ったリストである値を保持します。
html
<input type="range" id="b" name="b" value="50" /> +
<input type="number" id="a" name="a" value="10" /> =
<output name="result" for="a b">60</output>
例
仕様書
Specification |
---|
HTML # attr-label-for |
HTML # attr-output-for |
ブラウザーの互換性
html.elements.label.for
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
for |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
html.elements.output.for
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
for |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.