Re: [csswg-drafts] [css-box-4] Should margin-trim have a 'floats' value? (#3256)

The CSS Working Group just discussed `margin-trim vs floats`.

<details><summary>The full IRC log of that discussion</summary>
&lt;fantasai> Topic: margin-trim vs floats<br>
&lt;fantasai> github: https://github.com/w3c/csswg-drafts/issues/3256<br>
&lt;fantasai> miriam: Question is should floats be able to do margin-trim<br>
&lt;fantasai> miriam: It seemed to us that floats that are at the edge of the box that have a box that would impact the box should be considered the same as any other margin against the edge of the box<br>
&lt;fantasai> miriam: there might need to be special definitions to define precisely when floats are impacted<br>
&lt;fantasai> miriam: but don't need ability to control separately<br>
&lt;fantasai> florian: I think we need some amount of independence<br>
&lt;fantasai> florian: Antenna House Formatter has proprietary controls<br>
&lt;fantasai> florian: for e.g. controlling the margin between two floats differently from margin between float and edge of the page<br>
&lt;fantasai> florian: when being particular about layout of complex documents with floats<br>
&lt;fantasai> florian: (not floats as substitute for grid, but actual floats)<br>
&lt;fantasai> florian: then you do want that kind of control<br>
&lt;fantasai> florian: float to float margins and foat to text margins are often different<br>
&lt;fantasai> florian: Some amount of float margin trimming explicitly is needed<br>
&lt;fantasai> miriam: I was thinking if we think of the trim as coming from the box edge, we could maintain the exclusion box of the float with the margin so if it's pushing anything else that margin is still there, but it's trimmed as far as the box is concerned<br>
&lt;fantasai> miriam: that seems to make sense to me<br>
&lt;fantasai> miriam: and that wouldn't need manual control<br>
&lt;fantasai> iank_: Should this just apply to in-flow elements?<br>
&lt;fantasai> iank_: That seems to be the main use case here<br>
&lt;fantasai> iank_: ...<br>
&lt;fantasai> florian: What would apply then? If I do want to trim the margins of a float<br>
&lt;fantasai> florian: for the purpose of not pushing other floats apart, it would work, but if not, then we'd need another property<br>
&lt;fantasai> iank_: It's a bit hard for me to reason when we don't have particularly strong use cases one way or another<br>
&lt;fantasai> iank_: use case described seems to be for in-flow children<br>
&lt;fantasai> iank_: consider the out of flow position case, not intending to act on that<br>
&lt;fantasai> iank_: floats seem in-between to me<br>
&lt;florian> q-<br>
&lt;fantasai> miriam: If the section that the float is in is wrapping the float<br>
&lt;fantasai> miriam: e.g. is a block formatting context root<br>
&lt;fantasai> miriam: then I would expect the float the behave as in-flow wrt that box<br>
&lt;fantasai> miriam: the margins on the float would be pushing the size of the box which is exactly what we're trying to avoid here<br>
&lt;florian> fantasai: it makes sense to apply the trim to the float<br>
&lt;florian> fantasai: you want to have precise control over what is the visible edge<br>
&lt;florian> fantasai: if you consider a section with some text and a float…<br>
&lt;Rossen_> fantasai: I think that it makes sense to apply trim to floats. You want to have a solid control of the vis edge of the new box. Considersing a section with content and float that has margin, done so content doesn't clash. If on top however you want to trim it so that it doesn't get displaced compared to rest of content.<br>
&lt;Rossen_> florian: You need to trim all such margins. It makes sense to trim all of margins as well as inline.<br>
&lt;fantasai> iank_: for that specific case I don't think trimming the float is warranted<br>
&lt;Rossen_> q?<br>
&lt;Rossen_> ack fantasai<br>
&lt;fantasai> iank_: e.g. suppose you put 5px margin around the float, then want that to stay all around<br>
&lt;Rossen_> fantasai: not sure you want that margin necessary. Mostly vis content is what you want to align to. If you want to get the edge of flow and text to align so you can put a margin around you can. That way if float comes later in flow it has it but not at the top.<br>
&lt;Rossen_> fantasai: you can also skip using it. Use selectors for these first elements to remove margins etc.<br>
&lt;fantasai> jensimmons: I think it could be confusing if margin-trim works sometimes and not other times<br>
&lt;fantasai> jensimmons: "it counts if it's an image in a float, but not if ..." It's a lot to keep in your head<br>
&lt;emeyer> +1 to @jensimmons point<br>
&lt;fantasai> Rossen_: I'm closer to iank_'s opinion here... generally speaking, float layout is not inline layout<br>
&lt;fantasai> Rossen_: They take part during inline layout, however in all implementations floats are kept separately based on whether left or right float alignment<br>
&lt;fantasai> Rossen_: and float layout is wrt all floats themselves<br>
&lt;fantasai> Rossen_: We go to great extent in float algorithm in CSS2 to avoid and minimize the dependency an inline content and floats as much as possible<br>
&lt;fantasai> Rossen_: Position of float wrt content ...<br>
&lt;fantasai> Rossen_: seems odd<br>
&lt;fantasai> Rossen_: because even a float that comes in the beginning of the content, that more or less guarantees part of first line<br>
&lt;fantasai> Rossen_: That float can be left or right<br>
&lt;fantasai> Rossen_: and really left margin doesn't make sense for right float and vice versa<br>
&lt;fantasai> Rossen_: seems very specific to make that an automatic behavior by layout algorithm<br>
&lt;florian> q+<br>
&lt;iank_> e.g. https://www.software.hixie.ch/utilities/js/live-dom-viewer/?saved=9645<br>
&lt;Rossen_> fantasai: This is about trimming margins on content of all other layouts - block, flex items, grid items. etc.<br>
&lt;fantasai> fantasai: Should also trim floats<br>
&lt;fantasai> fantasai: Also not sure why concerned about inline layout, this isn't inline layout<br>
&lt;fantasai> Rossen_: Floats are out of flow<br>
&lt;miriam> q+<br>
&lt;fantasai> fantasai: Yes, they're taking out of their original position, but they're in-flow in the sense that they affect the content around them, unlike abspos<br>
&lt;fantasai> Rossen_: Floats create geometry for laying out content around it<br>
&lt;fantasai> Rossen_: Their placement takes place ahead of inline content around them<br>
&lt;Rossen_> q?<br>
&lt;fantasai> florian: You talked about inline margins<br>
&lt;fantasai> florian: Discussion is about block-start margin of the float being trimmed<br>
&lt;Rossen_> ack florian<br>
&lt;fantasai> florian: If you want to put a 1em margin around your floats to avoid the text of your float crashing against the surrounding text<br>
&lt;fantasai> florian: it doesn't necessarily mean you want your float to be 1em from the start of the block<br>
&lt;fantasai> florian: there's nothing to crash into above it<br>
&lt;fantasai> florian: it does depend on the document, but there are cases here<br>
&lt;fantasai> florian: Elika gave explanations already, did you want scans of books or something?<br>
&lt;fantasai> miriam: I would follow up with with what Jen said<br>
&lt;fantasai> miriam: There are interesting discussions from impl point of view<br>
&lt;fantasai> miriam: But from author point of view, not making sense<br>
&lt;fantasai> miriam: If I have a box and I want to trim the margins at the edge of the box<br>
&lt;fantasai> miriam: I would expect it to trim all the margins at the edge of the box<br>
&lt;fantasai> miriam: I wouldn't expect some difference because one is floated or not or whatever<br>
&lt;fantasai> miriam: ...<br>
&lt;fantasai> miriam: Also margin-trim is only applied at the box edges. It doesn't affect how content is flowing together<br>
&lt;fantasai> miriam: It determines what happens when I have a box and a float inside it or a paragraph or a header inside of it<br>
&lt;fantasai> miriam: I trim the margins when they are at the box edge, and those are the only margins I'm trimming<br>
&lt;fantasai> florian: I support miriam's position. If you simplify the value space and exclude one of them, you can still have individual control by using selectors<br>
&lt;fantasai> iank_: Apply to out of flow elements?<br>
&lt;fantasai> miriam: I would expect to things that impact the size of the box<br>
&lt;fantasai> florian: wrt abspos, whatever<br>
&lt;fantasai> Rossen_: For purposes of computing scrollable area, they do affect layout as an inline margin would<br>
&lt;fantasai> Rossen_: behavior that we just described with abspos element that has large margin bottom, would still create a large scroller with visibly nothing below<br>
&lt;Rossen_> ack miriam<br>
&lt;fantasai> iank_: Other thing I wanted to ask...<br>
&lt;fantasai> iank_: Example where using margin-trim is desirable but also margin-trim is desirable<br>
&lt;fantasai> iank_: How would I get that back, if it does apply to floats?<br>
&lt;iank_> https://www.software.hixie.ch/utilities/js/live-dom-viewer/?saved=9645<br>
&lt;fantasai> miriam: I think you would either use padding, or you would not use margin-trim in that case<br>
&lt;fantasai> miriam: if you want different impact on different elements, you would do it manually instead of using margin-trim<br>
&lt;fantasai> iank_: other question is, now that we have nesting, it's very easy to implement effectively margin-trim now<br>
&lt;fantasai> iank_: does the use case for margin-trim become less due to this?<br>
&lt;florian> fantasai: margin trim is going to effect all elements very simply, but with selectors you'd need to drill down to descendents<br>
&lt;florian> fantasai: margin collapsing makes that complicated<br>
&lt;florian> fantasai: that's why we don't do it on table cells with selectors, and why it'd be good here too<br>
&lt;fantasai> iank_: If I want margin on the float and not the in-flow, then what do I do?<br>
&lt;Rossen_> q?<br>
&lt;fantasai> fantasai: Then don't use margin-trim<br>
&lt;Rossen_> ack fantasai<br>
&lt;florian> fantasai: isn't that the same question as with multiple items at the top row of a grid? at that point you can't use margin trim<br>
&lt;fantasai> iank_: It is common to want margin on the float and not the rest of the content<br>
&lt;fantasai> fantasai: I think the reason you often see margin on floats and not in-flow content that's supposed to align is because in-flow content isn't visibly flush<br>
&lt;fantasai> fantasai: but we're working to make that possible, so you won't need to add margin to the float to make it look like it's visually aligned with the in-flow content<br>
&lt;Rossen_> q?<br>
&lt;fantasai> iank_: I don't think that's entirely true...<br>
&lt;fantasai> iank_: but maybe we should discuss in the issue<br>
&lt;fantasai> miriam: I don't entirely understand your example, Ian.<br>
&lt;fantasai> iank_: I would expect padding on the content<br>
&lt;fantasai> s/iank_/miriam/<br>
&lt;fantasai> Rossen_: I think this is a great discussion and I certainly want to see progress made here<br>
&lt;fantasai> Rossen_: the use cases that I just understood make sense<br>
&lt;iank_> https://www.software.hixie.ch/utilities/js/live-dom-viewer/?saved=9646 RHS still seems better?<br>
&lt;fantasai> Rossen_: But I also think we need to do some more careful thinking<br>
&lt;iank_> s/RHS/LHS<br>
&lt;fantasai> Rossen_: Maybe talk through use cases and narrow down what's possible and what's not, and try to figure out expectations<br>
&lt;fantasai> Rossen_: so maybe take up again later<br>
</details>


-- 
GitHub Notification of comment by css-meeting-bot
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/3256#issuecomment-925097339 using your GitHub account


-- 
Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config

Received on Wednesday, 22 September 2021 16:38:35 UTC