This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
Specification: http://www.whatwg.org/specs/web-apps/current-work/multipage/rendering.html Multipage: http://www.whatwg.org/C#the-fieldset-and-legend-elements Complete: http://www.whatwg.org/c#the-fieldset-and-legend-elements Referrer: http://www.whatwg.org/specs/web-apps/current-work/multipage/ Comment: Spec needs to make it clear that fieldsets are never narrower than kids Posted from: 98.110.194.132 by bzbarsky@mit.edu User agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:30.0) Gecko/20100101 Firefox/30.0
Simple testcase at http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=2871 which every UA I can find renders with the fieldset wide enough for the div to fit. This is kinda similar to what table-layout:auto table cells do, actually, but only in the horizontal direction.
Is there some way to describe this in CSS?
That is a super-weird behavior, and I didn't realize we all did that. No, there's nothing in CSS that would do that. A "min-width: min-content !important;" rule in the UA stylesheet would have the right effect, but would prevent authors from specifying their own 'min-width'. We'd need something independent that accomplished the same thing. Do we think that this is a necessary behavior, or just something weird and random that everyone inherited?
> No, there's nothing in CSS that would do that. Short of "display: table-cell", kinda. > Do we think that this is a necessary behavior It's hard to tell. This behavior in Gecko dates back to at least code added in https://bugzilla.mozilla.org/show_bug.cgi?id=23156 which was before my time (not often I get to say that!) and before people did sane things like decent commit comments and useful bug reports. :( Would be interesting to see whether other engines have a better idea of why the behavior is there.
Wait, I was thinking wrong. If we okay with sanifying this sufficiently, so that an author setting 'min-width' explicitly will change this behavior, then what I posed would do fine, just without the !important. That is, just put a "min-width: min-content;" rule in the UA stylesheet. Unless overridden (which is likely rare), that'll ensure that fieldsets never have less width than their widest child.
Do "reset.css"-style style sheets reset that? Do pages that use "reset.css"-style sheets depend on it not being reset? I've added what Tab suggested. Let me know if it's not compatible enough.
Checked in as WHATWG revision r8576. Check-in comment: Try to be more compatible in <fieldset> rendering rules. http://html5.org/tools/web-apps-tracker?from=8575&to=8576
Eric Meyer's CSS reset doesn't seem to set min-width, nor do the other 4 at http://www.cssreset.com/. But people doing "all: initial" would of course reset this property too....