HTML HTML Forms Choosing Options Create Checkboxes

Linking "Labels" to which attribute?

Hello, when i use labels, am i linking it to "id" or to the "name"? For example: <label for="test">Test</label> <input type="checkbox" id="test">

or should it be

<label for="anothertest">another Test</label> <input type="checkbox" name="anothertest">

2 Answers

Agnes Demes
Agnes Demes
6,604 Points

Hi, labels need to be linked to the id

Jack Weldon
Jack Weldon
1,696 Points

Labels should be linked to the id. If you're unsure in future you can always check by trying both and seeing which one creates the desired result.