@@ -33,8 +33,8 @@ npm install @material/textfield
3333
3434``` html
3535<label class =" mdc-text-field" >
36- <input type =" text" id = " my-text-field " class =" mdc-text-field__input" >
37- <label class =" mdc-floating-label" for =" my-text-field " >Hint text</label >
36+ <input type =" text" aria-labelledby = " label-id " class =" mdc-text-field__input" >
37+ <span class =" mdc-floating-label" for =" label-id " >Hint text</span >
3838 <div class =" mdc-line-ripple" ></div >
3939</label >
4040```
@@ -82,11 +82,11 @@ included as part of the DOM structure of a full width text field.
8282
8383``` html
8484<label class =" mdc-text-field mdc-text-field--textarea" >
85- <textarea id = " textarea " class =" mdc-text-field__input" rows =" 8" cols =" 40" ></textarea >
85+ <textarea class =" mdc-text-field__input" aria-labelledby = " label-id " rows =" 8" cols =" 40" ></textarea >
8686 <div class =" mdc-notched-outline" >
8787 <div class =" mdc-notched-outline__leading" ></div >
8888 <div class =" mdc-notched-outline__notch" >
89- <label for = " textarea " class =" mdc-floating-label" >Textarea Label</label >
89+ <span id = " label-id " class =" mdc-floating-label" >Textarea Label</span >
9090 </div >
9191 <div class =" mdc-notched-outline__trailing" ></div >
9292 </div >
@@ -97,11 +97,11 @@ included as part of the DOM structure of a full width text field.
9797
9898``` html
9999<label class =" mdc-text-field mdc-text-field--outlined" >
100- <input type =" text" id = " tf-outlined " class =" mdc-text-field__input" >
100+ <input type =" text" aria-labelledby = " label-id " class =" mdc-text-field__input" >
101101 <div class =" mdc-notched-outline" >
102102 <div class =" mdc-notched-outline__leading" ></div >
103103 <div class =" mdc-notched-outline__notch" >
104- <label for =" tf-outlined " class =" mdc-floating-label" >Your Name</label >
104+ <span for =" label-id " class =" mdc-floating-label" >Your Name</span >
105105 </div >
106106 <div class =" mdc-notched-outline__trailing" ></div >
107107 </div >
@@ -118,8 +118,8 @@ To disable the text field, add the `disabled` attribute to the `<input>` element
118118
119119``` html
120120<label class =" mdc-text-field mdc-text-field--disabled" >
121- <input type =" text" id = " disabled-text-field " class =" mdc-text-field__input" disabled >
122- <label class =" mdc-floating-label" for = " disabled-text-field " >Disabled text field</label >
121+ <input type =" text" aria-labelledby = " label-id " class =" mdc-text-field__input" disabled >
122+ <span class =" mdc-floating-label" id = " label-id " >Disabled text field</span >
123123 <div class =" mdc-line-ripple" ></div >
124124</label >
125125```
@@ -170,8 +170,8 @@ which is immediate sibling of `.mdc-text-field`. See [here](helper-text/) for mo
170170
171171``` html
172172<label class =" mdc-text-field" >
173- <input type =" text" id = " my-text-field " class =" mdc-text-field__input" >
174- <label class =" mdc-floating-label" for = " my-text-field " >My Label</label >
173+ <input type =" text" aria-labelledby = " label-id " class =" mdc-text-field__input" >
174+ <span class =" mdc-floating-label" id = " label-id " >My Label</span >
175175 <div class =" mdc-line-ripple" ></div >
176176</label >
177177<div class =" mdc-text-field-helper-line" >
@@ -187,8 +187,8 @@ See [here](character-counter/) for more information on using character counter.
187187
188188``` html
189189<label class =" mdc-text-field" >
190- <input type =" text" id = " my-text-field " class =" mdc-text-field__input" maxlength =" 10" >
191- <label class =" mdc-floating-label" for = " my-text-field " >My Label</label >
190+ <input type =" text" aria-labelledby = " label-id " class =" mdc-text-field__input" maxlength =" 10" >
191+ <span class =" mdc-floating-label" id = " label-id " >My Label</span >
192192 <div class =" mdc-line-ripple" ></div >
193193</label >
194194<div class =" mdc-text-field-helper-line" >
@@ -204,11 +204,11 @@ inside of text field component.
204204``` html
205205<label class =" mdc-text-field mdc-text-field--textarea" >
206206 <div class =" mdc-text-field-character-counter" >0 / 140</div >
207- <textarea id = " textarea " class =" mdc-text-field__input" rows =" 8" cols =" 40" maxlength =" 140" ></textarea >
207+ <textarea class =" mdc-text-field__input" aria-labelledby = " label-id " rows =" 8" cols =" 40" maxlength =" 140" ></textarea >
208208 <div class =" mdc-notched-outline" >
209209 <div class =" mdc-notched-outline__leading" ></div >
210210 <div class =" mdc-notched-outline__notch" >
211- <label for = " textarea " class =" mdc-floating-label" >Textarea Label</label >
211+ <span id = " label-id " class =" mdc-floating-label" >Textarea Label</span >
212212 </div >
213213 <div class =" mdc-notched-outline__trailing" ></div >
214214 </div >
@@ -230,8 +230,8 @@ by HTML5's form validation API.
230230
231231``` html
232232<label class =" mdc-text-field" >
233- <input type =" password" id = " pw " class =" mdc-text-field__input" required minlength =8 >
234- <label for = " pw " class =" mdc-floating-label" >Password</label >
233+ <input type =" password" aria-labelledby = " label-id " class =" mdc-text-field__input" required minlength =8 >
234+ <span id = " label-id " class =" mdc-floating-label" >Password</span >
235235 <div class =" mdc-line-ripple" ></div >
236236</label >
237237```
@@ -247,10 +247,10 @@ Un-styled Content (**FOUC**).
247247
248248``` html
249249<label class =" mdc-text-field" >
250- <input type =" text" id = " pre-filled " class =" mdc-text-field__input" value =" Pre-filled value" >
251- <label class =" mdc-floating-label mdc-floating-label--float-above" for = " pre-filled " >
250+ <input type =" text" aria-labelledby = " label-id " class =" mdc-text-field__input" value =" Pre-filled value" >
251+ <span class =" mdc-floating-label mdc-floating-label--float-above" id = " label-id " >
252252 Label in correct place
253- </label >
253+ </span >
254254 <div class =" mdc-line-ripple" ></div >
255255</label >
256256```
0 commit comments