In HTML standards;
- 2 same
name
attributes can be used in differentform
elements in the same html document. id
attribute has to be uniqure in the same html document.label for
requiresid
to work
So, the following is valid
<html>
<body>
<form id="form1">
<input name="abc">
</form>
<form id="form2">
<input name="abc">
</form>
</body>
</html>
However, the following is invalid if I use label for
** because id is not unique**
<html>
<body>
<form id="form1">
<label for="item">Click me</label>
<input name="item" id="item">
</form>
<form id="form2">
<label for="item">Click me</label>
<input name="item" id="item">
</form>
</body>
</html>
So, do I use label for
incorrectly or is this a bug related to label for
in standards?
You are only supposed to have a unique id for every selector on a webpage. Why? For starters, the id field is so you can hyperlink to the exact section of a page. you can have multiple classes but only 1 id with a particular name.
I think what you are looking for is value="" http://www.w3schools.com/html/html_form_input_types.asp
http://www.w3schools.com/css/css_selectors.asp