w3c/wai-evaluation-tools-list

<legend> as first child

iadawn opened this issue · 4 comments

iadawn commented

From @daniel-montalvo:

legend needs to be the first child of fieldset for this to work
https://html.spec.whatwg.org/multipage/form-elements.html#the-legend-element
I'd thought browsers would be more forgivable with this but it seems not

Where is this a problem? And what does it break by not having it that way?

iadawn commented

For example,

<div class="fieldheader">

 <fieldset class="field" id="purpose">
      <div class="fieldheader">
        <legend class="label-input">Purpose<span class="short-sub">(Required)</span></legend>
      </div>
      <p>What type of evaluations does this tool support?</p>

It results in the legend playing less nicely with screen readers. @daniel-montalvo may have more specfics.

Hi @mhansma96

Thanks for your work on this.

If the legend is not the first child of the fieldset, the screen readers do not read the contents of the legend as the user tabs through the form controls.

The HTML spec requires that the legend element be the first child of the fieldset element.
Now this works as expected.

Hi @daniel-montalvo
Thanks for the quick response and input! Good to hear that it works now.