WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: [External Sender]Use of label without input

for

From: Mallory
Date: Nov 15, 2019 12:26PM


I see loose orphan <label> elements all the time. Sometimes I have no idea what the developers were thinking.

But when they try to label a fieldset or a group of inputs (I see this with a label with for matching the id of a div with a radiogroup role too), I ding 'em and correct with a fieldset+legend.

Now the only weird one I've seen which was legit was a label + button. but that's an edge case. Buttons are labellable elements, but they usually have their own text. A common weird case is a label with tabindex made clickable to activate a hidden input type=file. I tell devs there to use a button instead of label and still have the onclick activate the hidden input-- they do this because input type=files are not styleable, and they vaguely remember something about clicking labels to focus/activate their controls, lol.

cheers,
_mallory

On Fri, Nov 15, 2019, at 8:07 PM, glen walker wrote:
> Depends what you mean by "legit". The list of "labelable elements" does
> not show that a fieldset can be labeled by a <label> element. Look at the
> last column of the table in
> https://www.w3.org/TR/html53/sec-forms.html#labelable-element.
>
> You'll get a parsing error if you try something like this:
>
> <label for="stuff">hello</label>
> <fieldset id="stuff"></fieldset>
>
>
> On Fri, Nov 15, 2019 at 11:56 AM Brian Lovely via WebAIM-Forum <
> <EMAIL REMOVED> > wrote:
>
> > So it looks like it's perfectly legit to use a label instead of a legend as
> > the group label of a fieldset element.
> >
> >
> >
> > > > >