6 out of 10 rated this helpful - Rate this topic

legend element | legend object

[This documentation is preliminary and is subject to change.]

Inserts a caption into the box drawn by the fieldSet object.

Document Object Model (DOM) Level 2 HTML Specification, Section 1.6.5HTML 4.01 Specification, Section 17.1

Standards information

HTML information

Closing Tagrequired
CSS Displayblock

DOM Information

Inheritance Hierarchy

 Node
  Element
   HTMLElement
     legend

Remarks

The first LEGEND element in a FIELDSET is used as the caption of the FIELDSET. Additional LEGEND elements are ignored.

 

 

Build date: 3/8/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
Styling Limitation - addendum
Same observation here -- behavior is different than 4 other browsers (Firefox, Safari, Opera, and Chrome).
.
While trying to fix a display issue where IE wraps DIV elements not exhibiting an explicit length (despite the absence of the "clear:" attribute), as I literally specified larger and larger arbitrary widths (until the DIV returned to its expected position in IE), the gap between the end of the legend text and the start of the border grew larger and larger, until the DIV popped up where it was supposed to be...but the gap turned out to be silly.
.

I'll have to explain to my clients that it's a limitation of IE (or perhaps blocks), since the other browsers render it "correctly" and (strangely) two other fieldsets intermixed with DIV's (on the same page) are just fine, with and without widths.

Styling limitation
There doesn't seem to be any way to change the gap between the legend and the fieldset border in Internet Explorer.