Horje
HTML for Attribute

Definition and Usage

When used together with the <label> element, the for attribute specifies which form element a label is bound to.

When used together with the <output> element, the for attribute specifies the relationship between the result of the calculation, and the elements used in the calculation.


Applies to

The for attribute can be used on the following elements:

Elements Attribute
<label> for
<output> for


How to add Three radio buttons with labels

The label element. Click on one of the text labels to toggle the related radio button.
index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The label element</h1>

<p>Click on one of the text labels to toggle the related radio button:</p>

<form action="/action_page.php">
  <input type="radio" id="html" name="fav_language" value="HTML">
  <label for="html">HTML</label><br>
  <input type="radio" id="css" name="fav_language" value="CSS">
  <label for="css">CSS</label><br>
  <input type="radio" id="javascript" name="fav_language" value="JavaScript">
  <label for="javascript">JavaScript</label><br><br>
  <input type="submit" value="Submit">
</form>

</body>
</html>

Output should be:

How to add Three radio buttons with labels

How to Perform a calculation and show the result in an <output> element

Output Example.

index.html
Example: HTML
<!DOCTYPE html>
<html>
<body>

<h1>The output element</h1>

<form oninput="x.value=parseInt(a.value)+parseInt(b.value)">
<input type="range" id="a" value="50">
+<input type="number" id="b" value="25">
=<output name="x" for="a b"></output>
</form>

<p><strong>Note:</strong> The output element is not supported in Edge 12 (or earlier).</p>

</body>
</html>

Output should be:

How to Perform a calculation and show the result in an <output> element




html for attribute

Type:
Develop
Category:
Web Tutorial
Sub Category:
HTML Attribute
Uploaded by:
Admin


Read Article
https://develop.horje.com/learn/1434/reference