Do we need both name and id? Can they be the same thing?

why did we put the the <label> data before the <input>? when i did this exercise first time, i got it wrong cause i put it after input. my question is does the order of them matter?

Seems the label before or using nesting is the way to go:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/label

1 Like

Very useful information regarding the input and for attribute. Saw many forms before and i was wondering why in this exercise the for attribute is used.
Now it’s very clear thanks @mtf

1 Like

I’m still having trouble comprehending the concept of ‘name’ and ‘id’. I get that the id references back to the ‘label for’ definition.

I just don’t understand what the purpose of ‘name’ is? I’ve read the thread and still am missing the need for this definition in the code.

Any guidance would be greatly appreciated.

I made a reply with working example:

where i deliberately made the name and id different to show the purpose of name. How does that not help? We use the name attribute to extract the data from the form.

It’s still not making sense to me.

Kindly,
Monica

What is making sense? Its quite common that we need to get the data from the form for processing.

for which we use name. Based on the name of a field, we can extract the input.