Why use the "for" keyword to bind a label in HTML?

html

Solution

It makes a click on the label focus the input element it is `for`.

In the example you posted, you simply click on the word `Male` or the radio button in order for it to get selected. Without this, you have a much smaller target to click...

If it's needed then is there some equivalent in HTML 5 or is it the same?

It is not required, but is good practice for labels that have a direct form element to focus on (it wouldn't make much sense for a label that doesn't have a counterpart on a form).

The syntax is the same for HTML 5.

Problem

Possible Duplicate: What is the For attribute for in an HTML tag? I have been trying to find this out. What is the reason for using the "for=" when you use a label in HTML? ``` <form> <label for="male">Male</label> <input type="radio" name="sex" id="male" /> <br /> <label for="female">Female</label> <input type="radio" name="sex" id="female" /> </form> ``` If it's needed then is there some equivalent in HTML 5 or is it the same?

Original source

Related problems