Bug 323711

Summary: Only a fieldset's rendered legend should shrink to fit
Product: WebKit Reporter: Morne <morne>
Component: Layout and RenderingAssignee: Nobody <webkit-unassigned>
Status: NEW    
Severity: Normal CC: bfulgham, karlcow, simon.fraser, webkit-bug-importer, zalan
Priority: P2 Keywords: InRadar
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   
See Also: https://bugs.webkit.org/show_bug.cgi?id=172718
https://bugs.webkit.org/show_bug.cgi?id=189650
https://bugs.webkit.org/show_bug.cgi?id=188643
https://bugs.webkit.org/show_bug.cgi?id=248087

Morne
Reported 2026-09-08 17:42:33 PDT
WebKit sizes every <legend> to its content, not just the one its fieldset renders in the border. RenderBox::sizesLogicalWidthToFitContent() groups HTMLLegendElement with input, select, button and textarea, so any legend with width:auto shrinks to fit. Per HTML only the rendered legend (the first in-flow <legend> child of a <fieldset>) is sized that way; any other legend is an ordinary block. Steps: 1. Put <legend>hello</legend> directly in the body. 2. Compare its computed width to an identically styled <div>. Expected: both fill the containing block. Actual: the legend shrinks to its content, and is 0px wide when empty. wpt.fyi for html/rendering/non-replaced-elements/the-fieldset-and-legend-elements/legend.html: Chrome 56/56, Firefox 56/56, Safari 49/56.
Attachments
Radar WebKit Bug Importer
Comment 1 2026-09-08 17:42:42 PDT
Morne
Comment 2 2026-09-08 17:45:38 PDT
Note You need to log in before you can comment on or make changes to this bug.