4.10.5 The legend element

Contexts in which this element can be used:
As the first child of a fieldset element.
Content model:
Phrasing content.
Content attributes:
Global attributes
DOM interface:
interface HTMLLegendElement : HTMLElement {
  readonly attribute HTMLFormElement? form;

The legend element represents a caption for the rest of the contents of the legend element's parent fieldset element, if any.

legend . form

Returns the element's form element, if any, or null otherwise.

The form IDL attribute's behavior depends on whether the legend element is in a fieldset element or not. If the legend has a fieldset element as its parent, then the form IDL attribute must return the same value as the form IDL attribute on that fieldset element. Otherwise, it must return null.