The "for" attribue

Hello all,

I am having trouble understand what the “for " attribute” does and why it has to be equal to an “id”. I’d appreciate the help.

Thank you,

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

So basically the for attribute states what id it is stating for.

if you do not have the input element nested inside the label and you want them connected (for screen-readers, for being able to click on the label and select the input…), you use a for attribute on the label equal to the id attribute to the input to link them