Multicol and Fragmentation

A presentation at CSS Day in June 2025 in Amsterdam, Netherlands by Rachel Andrew

Slide 1

Slide 1

Multicol and fragmentation Rachel Andrew, Developer Content Lead, Chrome.

Slide 2

Slide 2

CSS multiple-column layout

Slide 3

Slide 3

Flexbox and grid  Create a new formatting context for their direct children.  These children then participate in flex or grid layout.  Strings that are direct children of the flex or grid container get wrapped in an anonymous element, so they behave like other elements in layout.

Slide 4

Slide 4

Multicol  The direct children don’t do anything special.  The children continue to participate in block and inline layout.  They are fragmented into columns.

Slide 5

Slide 5

Fragmentation

Slide 6

Slide 6

Slide 7

Slide 7

Most of these are fragmentation tests

Slide 8

Slide 8

Fragmentation

Slide 9

Slide 9

Controlling breaks  break-before  break-after  break-inside  orphans  widows  box-decoration-break

Slide 10

Slide 10

Slide 11

Slide 11

Slide 12

Slide 12

.target { break-inside: avoid; }

Slide 13

Slide 13

Slide 14

Slide 14

.target { box-decoration-break: clone; }

Slide 15

Slide 15

Slide 16

Slide 16

https://webstatus.dev/stats

Slide 17

Slide 17

Slide 18

Slide 18

RenderingNG

Slide 19

Slide 19

Avoiding breaks before and after  break-before: avoid  break-after: avoid

Slide 20

Slide 20

CSS for print

Slide 21

Slide 21

Print and PDFs from the web

Slide 22

Slide 22

Paged Media  Paged Media Level 3: https://www.w3.org/TR/css-page-3/  Generated Content for Paged Media: https://drafts.csswg.org/css-gcpm/

Slide 23

Slide 23

Add content to page headers and footers

Slide 24

Slide 24

@page size descriptor @page { Define he size of the page you are printing to, and the size of the margins around the content. size: 8.5in 7in; }

Slide 25

Slide 25

Slide 26

Slide 26

@page margin at-rules  @top-left-corner  @right-top  @top-left  @right-middle  @top-center  @right-bottom  @top-right  @bottom-left-corner  @top-right-corner  @bottom-left  @left-top  @bottom-center  @left-middle  @bottom-right  @left-bottom  @bottom-right-corner

Slide 27

Slide 27

@page :right { @bottom-left { content: “My book”; font-size: 9pt; color: #333; } }

Slide 28

Slide 28

@page :right { @bottom-right { content: counter(page); } } @page :left { @bottom-left { content: counter(page); } }

Slide 29

Slide 29

Print things that browsers don’t do These things are all in the spec.

Slide 30

Slide 30

Set strings h1 { string-set: doctitle content(); } Add content from the HTML document to the page margin. @page :right { @top-right { For example, store the content of an <h1> element then output it. The content is updated if a new <h1> is encountered. content: string(doctitle); margin: 30pt 0 10pt 0; font-size: 8pt; } }

Slide 31

Slide 31

Cross-references Cross-references in print are indicated with the page number where the content is found.

<style> a.xref:after { content: ” (page ” targetcounter(attr(href, url), page) “)”; Cross-references on the web are a link. } With target-counter you can show a link for web presentations and the page number when the same document is printed. </style> <a class=”xref” href=”#ref1”>my reference</a>

Slide 32

Slide 32

Footnotes <style> .fn { When printed, footnotes are shown in the margin at the foot of the page on which they appear. float: footnote; } </style> They use a new value of float. <p>This is some text <span class=”fn”>this is a footnote</span>.</p>

Slide 33

Slide 33

Chrome bugs for these features  Set strings (20 +1s): https://crbug.com/376420244  Cross-references (33 +1s): https://crbug.com/40529223  Footnotes (13 +1s): http://crbug.com/376428674

Slide 34

Slide 34

We’ve become trained in what the web can’t do

Slide 35

Slide 35

text-wrap: balance h1 { text-wrap: balance; }

Slide 36

Slide 36

sIFR

Slide 37

Slide 37

Variable fonts

Slide 38

Slide 38

Slide 39

Slide 39

Are you pre or post responsive design?  The concept of responsive design is now 15 years old.  Bootstrap was launched in 2011.

Slide 40

Slide 40

By David Lark - Own work, CC BY-SA 4.0, https://commons.wikimedia.org/w/index.php?curid=42413988 Badgers, Mr. Weebl “The Holy Grail” on Wikipedia. https://en.wikipedia.org/wiki/Badgers_(animation)

Slide 41

Slide 41

CSS for developer experience A lot of new CSS gives us better ways to do the things we can already do

Slide 42

Slide 42

The web just doesn’t work like that

Slide 43

Slide 43

Creating rows in multicol Multiple-column Layout Level 2

Slide 44

Slide 44

Overflow columns in multicol .columns { column-count: 3; height: 100px; row-gap: 2em; }

Slide 45

Slide 45

Multicol Level 2

Slide 46

Slide 46

The column-height property .columns { column-count: 3; column-height: 100px; row-rule: 2px solid grey; row-gap: 2em; }

Slide 47

Slide 47

The column-wrap property .columns { column-count: 3; column-height: 100px; column-wrap: nowrap; row-rule: 2px solid grey; row-gap: 2em; }

Slide 48

Slide 48

height column-height

Slide 49

Slide 49

Slide 50

Slide 50

Gap decorations

Slide 51

Slide 51

Gap decorations: row-rule .columns { column-count: 3; column-height: 100px; column-wrap: wrap; row-rule: 2px solid grey; row-gap: 2em; }

Slide 52

Slide 52

Gap decorations with grid .grid-with-spans { display: grid; grid-template: repeat(4, 100px) / repeat(4, 100px); gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; }

Slide 53

Slide 53

Gap decorations with grid .break-none-grid { display: grid; grid-template: repeat(4, 100px) / repeat(4, 100px); gap: 20px; row-rule: 6px solid red; column-rule: 6px solid blue; rule-break: none; rule-outset: 0px; }

Slide 54

Slide 54

Gap decorations demos

Slide 55

Slide 55

Gap decorations demos

Slide 56

Slide 56

Is the web moving closer to paged media?

Slide 57

Slide 57

Floating an image to the top or bottom

Slide 58

Slide 58

Page or column floats

Slide 59

Slide 59

Column floats in Prince img { Snap the image to the top or bottom of a column, based on which edge is nearest. -prince-float: snap; }

Slide 60

Slide 60

column-span: <integer> .spanner { .spanner { column-span: all; } column-span: 2; }

Slide 61

Slide 61

Slide 62

Slide 62

Exclusions

Slide 63

Slide 63

Slide 64

Slide 64

Float an item lined up with a grid

Slide 65

Slide 65

Slide 66

Slide 66

CSS Exclusions issue

Slide 67

Slide 67

Regions? Like multicol, but with disconnected fragmaintainers.

Slide 68

Slide 68

Slide 69

Slide 69

Slide 70

Slide 70

Connective features Not exciting on their own, but act as multipliers and enablers of exciting things

Slide 71

Slide 71

Raise issues to show us the things you can’t do Don’t worry about how it’s done, explain what the use case is.

Slide 72

Slide 72

reading-flow Getting one of those impossible things done

Slide 73

Slide 73

reading-flow and reading-order

Slide 74

Slide 74

Thank you