Grouping Controls

Back to Overview
00:00 --> 00:08
Now, grouping controls are also super important because sometimes different form elements,

00:08 --> 00:10
they just belong together.

00:10 --> 00:17
So you want to make sure that that is clear to people using screen readers, to other assistive

00:17 --> 00:20
technology.

00:20 --> 00:27
And you're doing that basically by using controls with field sets.

00:27 --> 00:33
That's the easiest way and this is the only thing that I recommend from this page.

00:33 --> 00:42
So if you go to this section, associating related content with fieldset, then you'll

00:42 --> 00:44
see that there is a fieldset.

00:44 --> 00:50
In this case, it's named output format and it has three radio button text files, CSV

00:50 --> 00:55
file, HTML file, and you can select one of those.

00:55 --> 00:59
In the HTML, this basically looks like this.

00:59 --> 01:01
You have fieldset and legend.

01:01 --> 01:05
The legend always needs to be the first child of the fieldset.

01:05 --> 01:12
So if you're doing accessibility testing, you'll need to look out for that.

01:12 --> 01:15
But then you can basically do what you want after that.

01:15 --> 01:19
And here we have the input, the radio button.

01:19 --> 01:23
So that's type radio instead of type checkbox.

01:23 --> 01:28
And then we have "checked" because this is the first one and we want to have that automatically

01:28 --> 01:31
checked.

01:31 --> 01:37
Then we have the format "csv" and that is not checked and we have the label after that.

01:37 --> 01:41
Now what happens when a screen reader comes across this?

01:41 --> 01:49
It will read a CSV file, radio button selected in this case, and then it will say "output

01:49 --> 01:50
format".

01:50 --> 01:57
basically gives you that additional information that, oh yeah, this is the section for the output

01:57 --> 02:08
format. And that's especially important if you have multiple similar things. But let's first

02:08 --> 02:16
look at checkboxes. It's the same thing. Basically, so in this case, I want to receive the weekly

02:16 --> 02:19
newsletters offer from the company and that would be also

02:19 --> 02:26
announced as offers from offers from the company. Checkbox

02:26 --> 02:40
unchecked. And then I want to receive as the description. And

02:40 --> 02:43
here we have the example with the related fields. So in this

02:43 --> 02:49
case, we have duplicated name, street, number, city and subcode

02:51 --> 02:59
fields, input fields. So just having name input field does not

03:00 --> 03:04
give the user enough information because they should be able to

03:04 --> 03:08
distinguish between those use cases. So in this case, it's

03:08 --> 03:17
name, you know, edit text, and then shipping address, and then you have name, edit text,

03:17 --> 03:22
billing address. And it's like, oh, yeah, that makes a lot more sense than just having like name

03:22 --> 03:33
and street. And that can make it much easier to be mindful and knowing what's happening

03:33 --> 03:40
between those fields. Yeah, and the code is basically the same. Wrap it into fieldset,

03:40 --> 03:43
put the legend, which is in this case the shipping address,

03:44 --> 03:48
at the top, and then you put inside the fieldset whatever you want.

03:51 --> 04:01
Now, there is this note that the fieldset can sometimes be not announced, or it might be

04:01 --> 04:08
only announced when you enter the field set and stuff like that. That's all true. Users are used

04:08 --> 04:16
to how they have their screen reader configured. So don't worry about this. This has been

04:17 --> 04:27
around for a long time, so there's no need to really look at that and make sure that

04:30 --> 04:37
or make anything else in that situation. It's a really simple solution for a lot of use cases.