-
Notifications
You must be signed in to change notification settings - Fork 673
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
[css-break-4] Should margin-break apply to elements or fragmentation containers? #3314
Comments
Good point (also, welcome to the CSSWG, it's great to have you participate). I find it easier to reason about when thinking about individual elements than with fragmentainers, but it is true that we need to think through the implications on margin collapsing, and that your approach gives an easy way out of that problem. If we end up not taking your suggestion, I think we should be extra careful about what happens to collapsible margins with a different setting. As for use cases, it seems to me that something like this is reasonable: h1 {
margin-top: 5em;
break-before: right;
margin-break: keep;
}
h2, hr {
break-before: always;
margin-break: discard;
}
@media print { hr { border: none; } } This preserves a (large) top margin a the beginning of chapters, but drops it at the beginning of subsections (either marked by a lower level heading or by an |
We did also resolve to add a Wrt collapsing margins: if |
Actually, nevermind. That comment about collapsed margins is wrong, I was mixing it up with |
I'm not sure how multiple nested elements with collapsing top margins right after a page break should behave if their About |
Could you please confirm the following conclusions/assumptions and our reasoning behind them:
|
@bernhardf-ro Wrt #3314 (comment) that is my expectation, yes. (Please note this is just a first draft, so nothing is fixed here, we're still accepting comments on how exactly it should work.) |
Thanks @fantasai for the confirmation (And belated thanks @frivoal for the warm welcome.) With collapsing being applied last, I think the implementation side is safe. However, collapsing of nested elements seemingly changing truncated margins to non-zero values may be confusing for some authors. (In my personal experience margin collapsing, as it is, is already considered confusing by quite a few.) This may be solved by considering truncated margins to not be adjacent to any other margins or similar limitations to collapsing. I still believe the simpler approach, setting the property on the fragmentation container, would eliminate these problems entirely. The desired result in the sample above can be achieved without using Would adding properties for both elements and fragment containers, similar to |
In PDFreactor we have a property that works pretty much identically to
margin-break
(with a more convoluted name):https://www.pdfreactor.com/product/doc_html/index.html#css-property-ro-truncate-margin-after-break
https://drafts.csswg.org/css-break-4/#break-margins
There is, however, one major difference: Our property applies to the fragmentation containers.
Our reasons for this were:
.columcontainer
instead of.columcontainer h1, .columcontainer h2, .columcontainer p
or.columcontainer *
and@page
instead ofhtml, body, h1, h2, p
or*
margin
andmargin-break
values may result in hard-to-predict results, especially when the interaction with margin collapsing (e.g. in which order they are applied) is not obvious.Of course, I understand that the finer granularity of the per-element approach may solve some complex cases, but, to be honest, I haven't been able to come up with any.
While we will, of course, implement the specification when it is mature, I would like to know your opinions on these two approaches.
The text was updated successfully, but these errors were encountered: