WebAIM - Web Accessibility In Mind

E-mail List Archives

Re: RE: Long form legends

for

From: Jukka K. Korpela
Date: Jun 10, 2005 2:03PM


On Sat, 4 Jun 2005, Richard Garbutt wrote:

> This tutorial:
>
> http://www.picment.com/articles/css/funwithforms/
>
> seems great on styling forms. I like the way they mark them up:
>
> <code>
> <form>
> <fieldest>
> <label for="foo">foo</label>
> <input id="foo" type="text" name="foo" />
> </fieldset>
> </form>
> </code>

Unfortunately, that's invalid markup, and I don't mean just the
misspelling <fieldest> for <fieldset>. Contrary to what the cited document
claims, the <legend> element is _not_ optional. It is required by HTML
syntax, see
http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.10
(Even the spec is misleading: it says that "The LEGEND element allows
authors to assign a caption to a FIELDSET", but by the formal syntax,
<legend> is required.)

I don't think <fieldset> is particularly useful for a _single_ field. It's
useful for a _group_ of interrelated radio buttons and their captions, for
example.

Note: <legend></legend> would satisfy the syntax requirement, but it may
confuse people who use browsers that speak the legend.

--
Jukka "Yucca" Korpela, http://www.cs.tut.fi/~jkorpela/