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>

<label> および <output> の要素ページの使用例を参照してください。

仕様書

Specification
HTML
# attr-label-for
HTML
# attr-output-for

ブラウザーの互換性

html.elements.label.for

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
for

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

html.elements.output.for

Report problems with this compatibility data on GitHub
desktopmobile
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
for

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support