This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 13175 - Allow LEGEND to be LEGEND of FORM itself, without need for wrapping FIELDSET
Summary: Allow LEGEND to be LEGEND of FORM itself, without need for wrapping FIELDSET
Status: RESOLVED WONTFIX
Alias: None
Product: HTML WG
Classification: Unclassified
Component: LC1 HTML5 spec (show other bugs)
Version: unspecified
Hardware: All All
: P3 enhancement
Target Milestone: ---
Assignee: Ian 'Hixie' Hickson
QA Contact: HTML WG Bugzilla archive list
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-07-07 17:26 UTC by Marat Tanalin | tanalin.com
Modified: 2011-08-17 05:03 UTC (History)
7 users (show)

See Also:


Attachments

Description Marat Tanalin | tanalin.com 2011-07-07 17:26:23 UTC
http://www.w3.org/TR/html5/forms.html#the-legend-element

Often, LEGEND element is used as legend for FORM itself.

Currently, HTML spec requires LEGEND to be child of FIELDSET element, so to make legend for form itself, developers are forced to just wrap all form contents into one big FIELDSET to make it formally valid:

<form action="example"><fieldset>
	<legend>Example form</legend>
	<input type="text" name="test" />
</fieldset></form>

Such FIELDSET is completely redundant. So, it makes sense to allow LEGEND to be child of FORM itself, without need for wrapping FIELDSET:

<form action="example">
	<legend>Example form</legend>
	<input type="text" name="test" />
</form>

Thanks.
Comment 1 Tab Atkins Jr. 2011-07-07 17:34:10 UTC
Use a heading element (<h1>-<h6>).  <legend> is just one of the many names we have for heading elements in specific circumstances.
Comment 2 Marat Tanalin | tanalin.com 2011-07-07 17:39:15 UTC
(In reply to comment #1)
> Use a heading element (<h1>-<h6>).  <legend> is just one of the many names we
> have for heading elements in specific circumstances.

Using H1-H6 is one of (not quite elegant) alternatives that we are currently _forced_ to use.

The bug is about resolving this inconsistency. Legends inside forms are LEGEND elements.
Comment 3 Tab Atkins Jr. 2011-07-07 17:50:53 UTC
Using <h1> is a perfectly elegant and correct solution.  "legend" is just another word for "h1" (along with "figcaption", "summary", "title", "th", and a few other heading elements).

The only reason it exists is because (a) it has special rendering behavior in conjunction with <fieldset>, and (b) it was defined by an earlier version of HTML and exists in a lot of pages.

Neither of these reasons apply to the suggestion of using <legend> outside of <fieldset>.  If you want a heading for your form, use <h1>.
Comment 4 Marat Tanalin | tanalin.com 2011-07-07 18:05:54 UTC
(In reply to comment #3)
> Using <h1> is a perfectly elegant and correct solution.  "legend" is just
> another word for "h1" (along with "figcaption", "summary", "title", "th", and a
> few other heading elements).

Do you mean that we are free to arbitrarily use these elements in place of each other? For example, FIGCAPTION instead of TH, or TH instead of H1, or some another similar semantic soup? Really?

> The only reason it exists is because (a) it has special rendering behavior in
> conjunction with <fieldset>, and (b) it was defined by an earlier version of
> HTML and exists in a lot of pages.
>
> Neither of these reasons apply to the suggestion of using <legend> outside of
> <fieldset>.  If you want a heading for your form, use <h1>.

Main reason why legend is more suitable inside forms is that legend is semantically linked to specific fieldset/form element. It is not header of whole page, or nearest article parent element, it is header of exactly specific form or fieldset.
Comment 5 Tab Atkins Jr. 2011-07-07 18:31:02 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Using <h1> is a perfectly elegant and correct solution.  "legend" is just
> > another word for "h1" (along with "figcaption", "summary", "title", "th", and a
> > few other heading elements).
> 
> Do you mean that we are free to arbitrarily use these elements in place of each
> other? For example, FIGCAPTION instead of TH, or TH instead of H1, or some
> another similar semantic soup? Really?

No, I mean that they're all the same semantically.  Thus, there's no semantic difference between using <h1> in <form> (currently allowed) and using <legend> in <form> (currently not allowed).  Since there's no difference, just use the one that's already allowed.
Comment 6 Marat Tanalin | tanalin.com 2011-07-07 18:48:34 UTC
> I mean that they're all the same semantically.  Thus, there's no semantic
> difference between using <h1> in <form> (currently allowed) and using <legend>
> in <form> (currently not allowed).  Since there's no difference, just use the
> one that's already allowed.

A current acceptable solution does not prevent us from searching more suitable one. Legend is semantically more suitable (see comment 4 for reasoning). I personally would prefer LEGEND inside redundant FIELDSET instead of just abstract H1 header.

After all, if there is no difference between H1 and LEGEND, why LEGEND is required to be first first child of FIELDSET while H1 is not?
Comment 7 Michael[tm] Smith 2011-08-04 05:33:54 UTC
mass-move component to LC1
Comment 8 Ian 'Hixie' Hickson 2011-08-17 05:03:14 UTC
EDITOR'S RESPONSE: This is an Editor's Response to your comment. If you are satisfied with this response, please change the state of this bug to CLOSED. If you have additional information and would like the editor to reconsider, please reopen this bug. If you would like to escalate the issue to the full HTML Working Group, please add the TrackerRequest keyword to this bug, and suggest title and text for the tracker issue; or you may create a tracker issue yourself, if you are able to do so. For more details, see this document:
   http://dev.w3.org/html5/decision-policy/decision-policy.html

Status: Rejected
Change Description: no spec change
Rationale: <legend> has historically had such crazy parsing rules that it's prevented us from using it anywhere else at all (for example I originally wanted to use it instead of <figcaption> and <summary>). There's really no problem with using <h1> if you want a heading in a form.