zuluk zuluk - 16 days ago 7
HTML Question

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?:

<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?

Answer

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..