How do you associate a label with a specific form control when they are not nested?

  • By placing the label before the form control. 
  • Nesting the form control within a div with the label. 
  • Using the id attribute of the form control and the for attribute of the label. 
  • Using the name attribute of the label. 
To associate a label with a form control when they aren't nested, you utilize the for attribute on the label element. This for attribute should have the same value as the id attribute of the form control. By doing so, when a user clicks the label, the associated form control gets focus, enhancing accessibility and usability. 
Add your answer
Loading...