When A Label Only Has A Button, A Button Click Does Not (fully?) Trigger The Label
Solution 1:
A
labelcan only be associated with one form control at a time. This is evidenced by the fact that theforattribute points to an element with a matching ID attribute.You have a
buttonthat is a descendant of yourlabel; the expected interpretation of this is that thelabelserves as a label for thebutton. However, you're trying to associate the radio button, not thebuttonelement, with thelabel. The real problem here is that there is a conflict between the form controls and thelabel; it's unable to figure out which control it's supposed to be associated to.I'm guessing that the fact the radio button isn't working correctly is a side effect of this. Perhaps it's down to some activation behavior in both the radio button and the
buttonelement.I've checked that
buttons are legal children oflabels. Labels allow Phrasing Content, and buttons are Phrasing Content, so everything should be okay there.The validator does nevertheless produce the following error with your markup:
Error: Any
buttondescendant of alabelelement with aforattribute must have an ID value that matches thatforattribute.This is because a
labelelement with aforattribute needs to have a form control with that ID value for theforattribute to point to, even if that control is a descendant of thelabelitself. But you can't assign the same ID to more than one element. The result is the aforementioned conflict.Without knowing what you're trying to accomplish here, the best advice I can give if you just want the
labelto have the appearance of a button is to just style it as such.
Post a Comment for "When A Label Only Has A Button, A Button Click Does Not (fully?) Trigger The Label"