Repository navigation
Description
I've added an initial draft based on the resolution in #2923 (comment). That resolution resolved to add column-height with the suggestion that setting a value of column-height other than auto should trigger the creation of column rows, rather than new columns in the inline direction, as currently happens.
Using 'column-height' means that authors have the option, when creating these overflow rows to have additional space in the multicol container which can then be controlled by the alignment properties. For example:
.container {
block-size: 20em;
column-count: 3;
column-height: 5em;
}In this case,column-height is the trigger for rows. Assuming we have less content than would create rows that fill or overflow the block-size of the multicol container, there's extra space. I imagine this would then be controlled in the same way as additional space in a grid container after laying out columns, meaning you could center the multicol inside the container.
However, with column-height the trigger for wrapping this would mean you couldn't set a column-height yet keep inline column overflow, in the case that you wanted to have additional space in a multicol that was doing inline overflow. So you couldn't use the preceding example, keep inline overflow of columns then center the single line of columns inside the multicol container.
Also, using column-height to trigger wrapping seems a little magical and doesn't map to the way other things behave.
In my original suggestion I had proposed a column-wrap property to trigger the wrapping. My suggestion is to keep that as the trigger, but maintain this column-height property, as this will allow for the scenario mentioned, with inline overflowing columns and extra space, it also means that to get wrapping you asking for wrapping, rather than set a height on columns and something else happens.
Therefore, the following example would have a multicol container height of 20em, column-height of 5em. If there was too much content after filling three 5em tall columns, columns would be created in the inline direction. The extra space in the block direction could be distributed by the alignment properties.
.container {
block-size: 20em;
column-count: 3;
column-height: 5em;
}To get rows from this example, you add the column-wrap property. After the three columns are filled, a new row of three columns is created in the block direction, and this continues until all content is displayed. Again, if this results in spare space, this can be distributed by alignment.
.container {
block-size: 20em;
column-count: 3;
column-height: 5em;
column-wrap: wrap;
}Adding this to the agenda in the hope of getting a resolution on this property. If we resolve on this, there's a secondary point to resolve on.
What is the behavior, if the author sets column-wrap: wrap, a height on the multicol container, but column-height is auto. I think the two options are:
- Do nothing,
column-wrap: wraponly does something ifcolumn-heightis notauto. - Create new rows, if there is overflow, essentially resolving
column-heightto the available height of the multicol container, and creating new rows of that same size in the block direction.
My preference is 2, as then we maintain the trigger behavior of column-wrap, and it feels reasonable logical, but we'd need a decision one way or another should we adopt column-wrap and column-height.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsWednesday Afternoon
Activity
SebastianZ commentedon Feb 20, 2025
I agree that it makes sense to split the column height from whether additional columns are layed out in inline or block direction.
I just wanted to note that there's another way of thinking about this is like the auto-flow mechanism in Grid. I.e. a property similar to
grid-auto-flowthat takes eitherrow(default) orcolumnas values.Sebastian
rachelandrew commentedon Feb 24, 2025
I still think this behavior is more like flex wrapping than grid, and giving another property the value of
columnwhile in multiple column layout seems a bit confusing ... "do you want columns with those columns?"fantasai commentedon Mar 10, 2025
I don't think the use case of using the alignment properties to distribute space around fixed-height columns within the container is that compelling, so I think I'd lean towards not keeping
column-wrapin favor of automatically wrapping. We can introduce a value forcolumn-heightthat fills the containing block (stretch?) when it is definite, if that's a use case we want to serve.rachelandrew commentedon Mar 10, 2025
I'm not keen on
column-heighttriggering this behavior, I don't think it would be expected, and it seems clumsy to work around that in the future with another property just to avoid thecolumn-wrapproperty now.mstensho commentedon Mar 12, 2025
I really think that we want
column-wrap. Wrapping automatically ifcolumn-heightis non-auto (and small enough) seems too magical to me.I agree. The two properties should be set completely independently and not affect each other.
Meaning that what https://drafts.csswg.org/css-multicol-2/#cwr says for
column-wrapneeds to go away:I wonder if
column-wrapshould have a third valueauto, to support the current behavior, and always honor the value, regardless of media type.As the spec seems to be aware of, for paged media we always wrap. But this is also true for nested multicol.
This renders like:
Not like this:
Columns currently wrap if the multicol container lives inside another fragmentation context, be it paged media or another ancestor multicol.
mstensho commentedon Mar 13, 2025
Regarding
column-wrap:auto, though (my previous comment), is that going to cause trouble for thecolumnsshorthand?12 remaining items
mstensho commentedon Apr 9, 2025
Maybe it doesn't match with everyone's mental model of this, but there's essentially an implicit wrap between the two "A B" columns and the two "C D E F" columns, and between the two "C D E F" columns and the five "G H I J K" columns. Without these implicit wraps, there would be eleven columns next to each other on one row/line, like this, all in the first outer column:
Yes exactly, no
column-heightin my example. I'm just pointing out that there's already some sort of wrapping as it is (and has been for years), and that sometimes it wraps (between the first and second column, and again between the second and third column), and sometimes it doesn't (if the block-size is constrained, like in the third outer column). But maybe that's an other kind of wrapping that shouldn't be controlled bycolumn-wrap. Otherwisecolumn-wrap:auto(initial value) would resolve tonowrapin my example, and result in the rendering shown above, in this comment - which would break existing implementations.If we could explain lines and rows in the spec, and how they relate to each other, this might become a bit clearer.
rachelandrew commentedon Apr 9, 2025
That doesn't seem to be wrapping as we're defining it here though (I'm finding these examples hard to follow, but I don't see anything I'd describe as a "wrap") this is because you have one multicol nested inside another.
A regular multicol container has a single row, as we're defining it, inside which is at least one line of columns, but could be more if there is a spanner (that was the diagram I posted here). You only get multiple rows if you wrap. The
column-wrapproperty only controls those "overflow" columns. The ones that would currently go out in the inline direction and cause a scrollbar. I need to add all this to the multcol model part of the spec, maybe I'll get chance on Friday to do that.I feel like I'm just not getting your point about the nested columns, do you have a more realistic example or use case?
Bug 1958806 [wpt PR 51875] - Add `column-wrap: auto`., a=testonly
mstensho commentedon Apr 9, 2025
Nested multicol isn't very realistic, but it's similar to printing a multicol, which also gives you a nested fragmentation context.
I'm talking about this: https://drafts.csswg.org/css-break/#nested-flows
rachelandrew commentedon Apr 9, 2025
I understand when it happens, it's what you are describing as "wrapping" I don't understand.
mstensho commentedon Apr 9, 2025
When an inner multicol container breaks, it generates a new row. New row means wrapping, is what I'm thinking.
Let's do printing instead. Nested multicol is bad for the brain.
A new row of columns is started on the second page. If we hadn't done that, and instead let columns be as tall as they want, and cross page boundaries, all in a single row, it would have looked like this:
I.e. one would have to read the left column on all pages first, then turn back to page one and read the second column on all pages.
Bug 1958806 [wpt PR 51875] - Add `column-wrap: auto`., a=testonly
Bug 1958806 [wpt PR 51875] - Add `column-wrap: auto`., a=testonly
Bug 1958806 [wpt PR 51875] - Add `column-wrap: auto`., a=testonly
Bug 1958806 [wpt PR 51875] - Add `column-wrap: auto`., a=testonly
rachelandrew commentedon Jun 20, 2025
Back looking at this after an I/O induced hiatus...
So, I believe this new behavior will never occur in paged contexts, which don't have overflow columns, because in paged media we have this forced break. In the multicolumn model section we have:
and also for spanners:
We're already defining this as lines. So we wouldn't expect gaps and rules, for example, to go between lines, whereas we do expect them to go between rows.
In addition, in continuous contexts where we do have multiple rows, each row could contain multiple lines (due to spanners, as in the diagram in #11976 (comment)). So I think the wrapping you are talking about is the wrapping of lines, and not this sort of author-dictated wrapping in continuous contexts.
(I'm working on adding essentially what I've just described to the model section of the spec.)
mstensho commentedon Jun 23, 2025
Thank you. I think this is where my confusion came from. Lines, not rows. As long as
column-heightisn't used, there'll be no change.Here's a pagination example that does use
column-heightandcolumn-wrap:nowrap, though:This currently gets rendered like this in Chrome (with the feature enabled):
Which is correct, I guess? We run out of columns (2), and keep overflowing in the inline direction, even if we're paginated.
rachelandrew commentedon Jul 30, 2025
Yes, in this case we carry on in the inline direction because we've explicitly said to
nowrap.I think a lot of the above discussion just needs the updates to the multicol model section of the spec to define all the bits and how they relate to each other. We agreed to just leave this issue open and make a decision about whether to keep
column-wraplater, I don't think we ned to resolve on this to progress the other issues so leaving it on hold for now.mstensho commentedon Sep 16, 2025
If you want to create a vertical carousel using column wrapping on a scrollable container, and there is no
column-wrapproperty, and you don't want to specify a fixedcolumn-height(which you don't want to if all you want is to use available space), then how can we get multiple rows?The initial value of
column-heightisauto, and this does not enable multicol (nor wrapping). We could add another keyword value forcolumn-heightand let that value enable multicol and wrapping to solve this.Or, we can keep
column-wrap?Bug 1958806 [wpt PR 51875] - Add `column-wrap: auto`., a=testonly