I have been researching this issue for a 508 accessibility assignment and from the sounds of it using fieldsets and legends are an alternative to using role="group", role="radiogroup", etc. and vice versa. Is this correct or should I be using both elements in tandem with one another? So for instance would the following code be correct?
<fieldset>
<legend class="h3">Which products interest you?</legend>
<div class="controls" role="group">
<!-- Multiple Checkboxes -->
<input class="checkbox-btn-control" id="medical-non-medicare" type="checkbox" name="product1" value="Medical (not eligible for Medicare)" aria-label="Medical (not eligible for Medicare)">
<label for="medical-non-medicare">Medical (not eligible for Medicare)</label>
<input class="checkbox-btn-control" id="dental" type="checkbox" name="product2" value="dental" id="Dental">
<label for="dental">Dental</label>
<input class="checkbox-btn-control" id="medicare-advantage" type="checkbox" name="product3" value="Medicare Advantage" aria-label="Medicare Advantage">
<label for="long-term-care">Medicare Advantage</label>
</div>
</fieldset>
According to the W3C, default aria role for fieldset
is "group"
So you may define the role
with the value "group" on a fieldset
(which is redundant and unnecessary but permitted).
What you can't do is defining another value that "group" on the role
attribute for fieldset
elements
In your example, the problem is that you'll have two different elements with the role=group
value (fieldset
and div
). I would say that the inner one may have precedence and prevent your screenreader from accessing the legend
element.