google/material-design-lite
View on GitHubText Field does not support implicit label association
Open
#1737 opened on Oct 13, 2015
Textfieldhelp wantedresearch
Description
The HTML spec allows for an implicit association between a label and an input by making the input a descendant of the label. This avoids the need for an associating for attribute, which can be problematic when generating dynamic markup because element identifiers must be unique across the entire page. Using an implicit association avoids the need for id or for attributes altogether. You can work around this by generating a unique identifier when generating the markup - but that's a little inconvenient.
So instead of:
<div class="mdl-textfield mdl-js-textfield">
<input class="mdl-textfield__input" type="text" id="sample1" />
<label class="mdl-textfield__label" for="sample1">Text...</label>
</div>
It would be convenient to be able to do this:
<div class="mdl-textfield mdl-js-textfield">
<label class="mdl-textfield__label"><input class="mdl-textfield__input" type="text" /> Text...</label>
</div>
http://www.w3.org/TR/html5/forms.html#the-label-element
The MDL textfield does not appear to support this arrangement.