Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTML: test inline margin on fieldset's legend #12569

Merged
merged 3 commits into from
Sep 18, 2018

Conversation

zcorpan
Copy link
Member

@zcorpan zcorpan commented Aug 20, 2018

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the top margin ends up affecting the position of the fieldset, but bottom margin affects the height of the fieldset?

@zcorpan
Copy link
Member Author

zcorpan commented Aug 20, 2018

Yeah, that's the effect of it.

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems weird, but if that's what implementations do...

@zcorpan
Copy link
Member Author

zcorpan commented Aug 20, 2018

It's what Edge does, and what I think is most useful. WebKit and Chromium ignore margin-top, which is not so useful. Gecko positions the fieldset's top border centered around the legend's margin box (as opposed to border box), which is not so visually pleasing as the legend ends up hanging inside or outside the fieldset.

left: 0;
right: 0;
top: 150px;
height: 220px;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this really behavior we want to standardize on? Looks like this test expects the legend's top margin to collapse with that of the fieldset, even though the fieldset has a border, AND both elements establish a BFC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW, I'd personally be okay with ignoring margin altogether (or just ignoring margin-top) as well.

Copy link
Member Author

@zcorpan zcorpan Aug 21, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can ignore margin in the block flow direction. @MatsPalmgren @dholbert @emilio any opinions?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't find the LEGEND block margins useful at all. Since interoperability is so lousy in this regard anyway, it would be tempting to say that we just ignore them.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug where margin-bottom was implemented for WebKit
https://bugs.webkit.org/show_bug.cgi?id=35981

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. There's nothing in that bug report that points out the usefulness of supporting margin-bottom on legend, though, is there? Might as well use padding-top on the fieldset, right?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I agree.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. There's nothing in that bug report that points out the usefulness of supporting margin-bottom on legend, though, is there? Might as well use padding-top on the fieldset, right?

Seems like it -- though in Firefox, you can use margin-bottom values to move the legend outside of the fieldset's border entirely (which you can't do with padding-top, but you could achieve with relative positioning instead). That special margin-bottom behavior doesn't seem to happen in other browsers, so I'm happy to see that behavior go, anyway.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One could use relative positioning to achieve that if desired.

@MatsPalmgren
Copy link

Using relative positioning or padding to a simulate a legend margin seems like a hack to me.

I tend to think we should support block-axis margins on the rendered legend. It's the most logical property to reach for when you want to create some distance to the surrounding content and it would be inconsistent if it doesn't work on legends when it applies to all other boxes (except inlines). Exceptions like this makes the web platform harder to understand and teach IMO. Margin properties are working fine on <caption> and I see no reason why we can't make it work similarly on <legend>.

Also, margin-bottom works fine in both Firefox and Chrome currently and I see no reason to change that.

@dholbert
Copy link
Contributor

dholbert commented Aug 21, 2018

margin-bottom works fine in both Firefox and Chrome currently and I see no reason to change that.

It does something quite different in Firefox vs Chrome right now, FWIW. Testcase: https://jsfiddle.net/28xhe3sj/

In Firefox, the legend is way outside the fieldset border there, for reasons that @zcorpan alluded to above. Whereas in Chrome, on the other hand, it just renders as if there were extra padding at the top of the fieldset's content box.

Using relative positioning or padding to a simulate a legend margin seems like a hack to me.

The margin-bottom usage/behavior feels like more of a hack to me than a more declarative padding/relpos setup, FWIW. The effect of <legend style="margin-bottom:Npx"> in Firefox right now is pretty bizarre -- it offsets the fieldset-border downwards by N/2 px, and then it offsets the fieldset's contents downward by the remaining N/2 px. If a site really wants the "legend detatched from the fieldset" look that Firefox (and only Firefox) gives them, it seems more direct for them to use relative positioning to shift the legend upwards by a precise amount, and to not arbitrarily offset the fieldset's contents downwards unless they really want that as well (in which case they can specify whatever fieldset padding they want).

@wpt-pr-bot wpt-pr-bot requested a review from emilio August 27, 2018 13:52
@zcorpan zcorpan force-pushed the zcorpan/fieldset-legend-margin branch from 0e1a69f to d5c5158 Compare August 27, 2018 13:54
@zcorpan
Copy link
Member Author

zcorpan commented Sep 11, 2018

@MatsPalmgren can we land this?

@zcorpan
Copy link
Member Author

zcorpan commented Sep 14, 2018

@MatsPalmgren @mstensho PTAL

@mstensho
Copy link
Contributor

I can't build the spec anymore, caused by the last commit:

$ ../html-build/build.sh
[...]
Generating HTML variant...
Error: Unused reference: [COMPAT]
Error count: 1
Saving index-html
Splitting...
Saving index.html
Saving introduction.html
[...]
Saving acknowledgements.html
Generating DEV variant...
Warning: Could not find ID selector-read-only for annotation that uses URLs:
https://caniuse.com/#feat=css-read-only-write
Splitting...
Saving index.html
Saving introduction.html
[...]
Saving acknowledgements.html
Generating SNAP variant...
Error: Unused reference: [COMPAT]
Error count: 1
Saving index-snap

There were errors. Stopping.

@zcorpan
Copy link
Member Author

zcorpan commented Sep 14, 2018

Oops, fixed.

@zcorpan
Copy link
Member Author

zcorpan commented Sep 17, 2018

I had forgotten about this and made #13040 so now I've removed the block margin tests here.

@mstensho
Copy link
Contributor

Can you rename the commit comment to say "inline margins", then?

@zcorpan zcorpan changed the title HTML: test margin on fieldset's legend HTML: test inline margin on fieldset's legend Sep 18, 2018
@zcorpan zcorpan merged commit c033091 into master Sep 18, 2018
@zcorpan zcorpan deleted the zcorpan/fieldset-legend-margin branch September 18, 2018 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants