Computer >> Computer tutorials >  >> Programming >> HTML

How to specify which form element a calculation is bound to with HTML?


Use the for attribute in HTML to specify which form element a calculation is bound to with HTML.

Example

You can try to run the following code to implement the for attribute −

<!DOCTYPE html>
<html>
   <body>
      <p>Education:</p>

      <form action="">
         <label for = "graduate">Graduate</label>
         <input type = "radio" name = "education" id = "graduate" value = "graduate"><br>

         <label for = "ugraduate">Under-graduate</label>
         <input type = "radio" name = "education" id = "ugraduate" value = "ugraduate"><br>
         <input type = "submit" value = "Submit">
      </form>

   </body>
</html>