Closed jrhorn424 closed 8 years ago
Related #11 and #2
html5 allows for embedding inputs in labels. This eliminates the need for ids to relate the labels to their inputs, e.g.
<label>
Label Text
<input type="text" name="bob">
</label>
I thought the 'for' in a label was what related it to it's input?
for="<id of input>"
creates the relation, so the input then needs an id
.
Ids on inputs aren't that useful. Names, which are form scope, are preferred for almost all use cases.
Wrapping the input in the label removes the need to connect via and id which must be unique for the document.
@raq929 If you'd like to discuss further, I'm happy to here or in person.
Ids on inputs aren't that useful. Names, which are form scope, are preferred for almost all use cases.
:heart:
IDs have a number of restrictions that other attributes don't have. In the first project, there is a temptation to use IDs to easily grab inputs instead of spending the cognitive load to write a good selector. This habit, if unchecked, leads to developer code like this:
CSS best practices suggest never selecting for styles on IDs. IDs should only be used sparingly in javascript. Our sass linter warns on this, so the earlier we explain that there are better selector strategies, the better.