Why must there be a “name” and “for” attribute? Can’t the code work without them?
Are `name`, `id`, and `for` required? Can they be the same? And what is the relationship between them?
What difference are there between name and id attribute?
for attribute uses the
id to associate input field and label, the id also can be used for styling
Do “id”, “name” and “for” attributes require the same name ?
for should have the same name, given this associates the label with the input element.
name doesn’t have to be the same, but i quite often do, because you want to have a logic name (one that make sense for the input field)
What happens if we omit the attribute “for” in label tag.Does it makes any difference?
the for attribute associates the label with the input element, omitting could cause problems for disability aid tools for example.
Why should the value in name attribute of input should match the value of for attribute of label?
I can understand for(of label) should match with id(of input).
It works just fine when name does not match with for. Why does the exercise insist on both values being the same?
the name attribute doesn’t have too match the for attribute, yet very often these names are the same. Why? Because its the most logic/descriptive name available.
in this exercise, why we don’t need to value?
as told previously, the input sent the user input with name=value to site, but here seem its ok to not using value. am i right?
the text area is not self closing, as such the value can be between the opening and closing tag (just like a paragraph, span and so forth), so we don’t need the value attribute
thank you, but i ask about password input, not text area (of corse i did did not know the notice you mentioned, thanks for that )
i read text area, so that is what i answered
as for password input, using the
value attribute will set the default for the input field (password in this case), we don’t want to set a default password (security risk/nightmare), so the user has to enter their password.
you’r right, thanks for answer.
how do u give correct usernames and passwords for form submission
Like a login system? You would need to compare the username and password with stored credentials.