Search code examples
htmllegendfieldsetjaws-screen-reader

Is a h3-tag allowed within legend of fieldset?


I have developed an application with forms. These forms are structured with fieldsets so you can see which input fields belong to a section. Each fieldset has a legend. The code looks like:

<fieldset>
  <legend>Title</legend>
  <label>Title: <input id="title" type="text"/></label>
  <button>Create Object</button>
</fieldset>

Now we did a screenreader test, because we have blind users. We mentioned, that the screenreader (JAWS) reads the Title in legend just as normal text. So it reads:"Title. Title. Input for title." However we expect sth like: "Caption Title. Title. Input for title."
The user said it would be better if the legend would be a caption so she can jump to section with a JAWL-command.

Now my question is: Is it allowed (HTML specification) to wrap the filedset-legend around a e.g. h3 tag? - Better question: Does it matter for an internal application, if I put a h3-tag inside the legend-tag even it is not w3c-conform?:

<fieldset>
  <legend><h3>Title</h3></legend>
  <label>Title: <input id="title" type="text"/></label>
  <button>Create Object</button>
</fieldset>

If it is not allowed what would be your solution for this issue? Programming an customized fieldset?

The goal is that the screenreader makes a difference between legend-text and normal text when reading the page. How can I achieve this?


Solution

  • Personally i would rather provide for my users than stick to the rules when it comes to this.

    If you do indeed use a h3 tag in your legends, so be it - your users will be most grateful. The only person that wins by sticking to valid html here is you, and that's of no benefit to the user. -- However, im not sure you actually need a fieldset/legend here.

    As OP is using this for an internal app / intranet, i beleive it is perfectly ok to disregard SEO and search engine / spiders..