WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: Using <legend> and <fieldset> on a single drop-down.

for

From: Graham Armfield
Date: May 28, 2021 5:08AM


Hi Ksenia,

Echoing what Mark Magennis said - a <legend> should always be used with a
<fieldset>.

The combination is used to label any group of input fields. It's also
possible to nest a <fieldset> inside another. For example, you may have
some grouped input fields about a particular person in an insurance
application that includes a radio button group. The radio button group
obviously needs to be in a <fieldset> with a <legend> and this can be
inside your other group. Obviously the more nesting you do, the more
complex the announcements.

One other thing that I have found in the past is that the <legend> element
needs to be the first child element of the <fieldset> or not all screen
readers will announce it. But I must admit that I haven't tested that for a
couple of years so that may no longer be the case.

Regards
Graham Armfield

coolfields.co.uk <http://www.coolfields.co.uk/>;
M:07905 590026
T: 01483 856613
@coolfields <https://twitter.com/coolfields>


<http://www.avg.com/email-signature?utm_medium=email&;utm_source=link&utm_campaign=sig-email&utm_content=webmail>
Virus-free.
www.avg.com
<http://www.avg.com/email-signature?utm_medium=email&;utm_source=link&utm_campaign=sig-email&utm_content=webmail>
<#DAB4FAD8-2DD7-40BB-A1B8-4E2AA1F9FDF2>

On Fri, 28 May 2021 at 11:22, Mark Magennis < <EMAIL REMOVED> >
wrote:

> Hi Ksenia,
>
> A fieldset is just a group of related fields that have a group name in
> addition to their individual names. So if your language dropdown is in a
> group of related controls then a group name might be sensible. The fieldset
> can have only one field in it if the group has a variable number of items
> in it but sometimes only one. E.g. "Color. Checkbox Red". Red is the field
> label and Color is the group label. But in this case there is only one
> color available so the group contains only one item. At other times it may
> also contain checkboxes for Blue, Yellow, etc.
>
> But the group name (legend) would need to be in a group (fieldset) that it
> names, otherwise it doesn't name anything.
>
> Mark
>
>