WebAIM - Web Accessibility In Mind

E-mail List Archives

Thread: questions about fieldset & legend

for

Number of posts in this thread: 3 (In chronological order)

From: Lori Brown
Date: Tue, Sep 05 2006 7:50AM
Subject: questions about fieldset & legend
No previous message | Next message →

Dear listers --

I hope this is the proper forum for the following questions which I have not
been able to google answers for:

1) I get a validation error for putting an <h3> heading inside of a fieldset.
(on validator.w3.org). It's the 'you can't put that element here' error. Can
anyone please explain this?

2) On the same small form, I have a fieldset but no legend, as I regarded such
text as unnecessary -- all the fields have labels, it's a tiny form, etc. But
the validator is telling me I am missing the opening tag for the legend, and
asking for it, even though there are no legend tags at all on the page. Again,
can anyone explain this?

3) I have long assumed that hidden form fields do not need any labels or
accessibility accoutrements. Is this true?

If you are able to answer, please copy me off-list, as I receive this mailing
list in digest form.

Thanks in advance.

Lori Brown
Sr. Web Developer
--
Earth Resources Technology, Inc.
8106 Stayton Drive
Jessup, MD 20794
Tel: (240)554-0161





From: Jared Smith
Date: Tue, Sep 05 2006 9:00AM
Subject: Re: questions about fieldset & legend
← Previous message | Next message →

Lori Brown wrote:
> 1) I get a validation error for putting an <h3> heading inside of a fieldset.
> (on validator.w3.org). It's the 'you can't put that element here' error. Can
> anyone please explain this?

It looks like this is the result of not having a legend. See below.

> 2) On the same small form, I have a fieldset but no legend, as I regarded such
> text as unnecessary -- all the fields have labels, it's a tiny form, etc. But
> the validator is telling me I am missing the opening tag for the legend, and
> asking for it, even though there are no legend tags at all on the page. Again,
> can anyone explain this?

legend is required within fieldset in HTML, but not in XHTML. I'm not sure
the reasons for this difference. If you're getting a failure, I assume you
are using HTML. I did some tests and the validator seems to validate these
correctly across versions.

The legend element cannot contain block level elements, so your <h3> would
need to go either before the fieldset or after the legend. Unfortunately
you cannot assign headings as legends, though this would certainly be
useful as the legends often designate document structure.

fieldset and legend have always been difficult elements to work with and
they will remain this way until HTML allows better styling for them and
the browsers decide to support them in a more consistent manner. If you're
using HTML, be sure to close the element (for instance, with </p>)
immediately before the opening <fieldset> or things will work oddly across
browsers.

> 3) I have long assumed that hidden form fields do not need any labels or
> accessibility accoutrements. Is this true?

Yes, that's correct.

Jared Smith
WebAIM.org





From: Jim Thatcher
Date: Tue, Sep 05 2006 10:10AM
Subject: RE: questions about fieldset & legend
← Previous message | No next message

> legend is required within fieldset in HTML, but not in XHTML.

Though required, the legend can be empty.

Jim

Accessibility Consulting: http://jimthatcher.com/
512-306-0931

-----Original Message-----
From: = EMAIL ADDRESS REMOVED =
[mailto: = EMAIL ADDRESS REMOVED = ] On Behalf Of Jared Smith
Sent: Tuesday, September 05, 2006 9:53 AM
To: WebAIM Discussion List
Subject: Re: [WebAIM] questions about fieldset & legend

Lori Brown wrote:
> 1) I get a validation error for putting an <h3> heading inside of a
fieldset.
> (on validator.w3.org). It's the 'you can't put that element here' error.
Can
> anyone please explain this?

It looks like this is the result of not having a legend. See below.

> 2) On the same small form, I have a fieldset but no legend, as I regarded
such
> text as unnecessary -- all the fields have labels, it's a tiny form, etc.
But
> the validator is telling me I am missing the opening tag for the legend,
and
> asking for it, even though there are no legend tags at all on the page.
Again,
> can anyone explain this?

legend is required within fieldset in HTML, but not in XHTML. I'm not sure
the reasons for this difference. If you're getting a failure, I assume you
are using HTML. I did some tests and the validator seems to validate these
correctly across versions.

The legend element cannot contain block level elements, so your <h3> would
need to go either before the fieldset or after the legend. Unfortunately
you cannot assign headings as legends, though this would certainly be
useful as the legends often designate document structure.

fieldset and legend have always been difficult elements to work with and
they will remain this way until HTML allows better styling for them and
the browsers decide to support them in a more consistent manner. If you're
using HTML, be sure to close the element (for instance, with </p>)
immediately before the opening <fieldset> or things will work oddly across
browsers.

> 3) I have long assumed that hidden form fields do not need any labels or
> accessibility accoutrements. Is this true?

Yes, that's correct.

Jared Smith
WebAIM.org