HTML, accessibilty: is it possible to tag two controls with the same label?

I found an example on the net where the tag tag and its “for” attribute were used to prompt the browser that owns the tag management. For instance:

<form>  
  <label for="male">Male</label>
  <input type="radio" name="sex" id="male" />
  <br />
  <label for="female">Female</label>
  <input type="radio" name="sex" id="female" />
</form>

My question is that I actually have two controls where the same single label should be assigned to a combination of both (not possible), for example:

a label text + a numeric input field + a text (unit) input field  

Should I

  • label only the numerical input field (because it’s not possible) or
  • Is it possible to put a numeric and text input field in one span tag and bind a label to this range?
  • or can both input controls be placed inside the tag tag?

Which solution will work for accessibility in all browsers?

+3
1

for ( ID), . , .

spec:

for = idref [CS]

, . id - . , .

, LABEL. LABEL .

( )

+7

Source: https://habr.com/ru/post/1788459/


All Articles