google / google/material-design-lite

Text Field does not support implicit label association

Open
#1,737 4 comments 0 reactions 0 assignees View on GitHub
help wanted research Textfield
Dominant language
HTML
Stars
32.2k
Forks
4.9k
PR merge metrics
No merged PRs in 30d

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:

``` html



Text...

```

It would be convenient to be able to do this:

``` html


Text...

```

http://www.w3.org/TR/html5/forms.html#the-label-element

The MDL textfield does not appear to support this arrangement.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.