Numbers, tables and totals / Batch and serial number list
Listing serial numbers under a line without breaking the row
Identifiers attached to a delivered item, printed under the line they belong to, where one line can carry one identifier or four hundred.
Why this block is harder than it looks
A serial number list is a variable-length block nested inside a table row, which is the worst combination in the cluster. Keeping a row atomic is the usual advice and it is exactly wrong here: a row carrying two hundred serials cannot fit on a page, so break-inside: avoid on that row means the renderer overrides you and breaks it somewhere arbitrary. The identifiers themselves are also long alphanumeric strings that a person may have to transcribe, so they need the same legibility treatment as bank details, at a much smaller size and in much greater quantity.
The decisions that make it work
Reasons rather than a description of the code. Each of these is a choice that has a wrong answer, and the wrong answer is usually the default.
- Set break-inside: avoid on ordinary rows and remove it from any row carrying a serial list, so the list is allowed to break at a place of its own choosing rather than at a place forced on it.
- Set the identifiers in columns inside the cell so a hundred of them occupy five centimetres rather than forty, and let the columns break across pages.
- Use a monospace face and tabular figures. These are transcribed by hand more often than any other field on a delivery note.
- Group in tens with a hairline or a small gap, so somebody counting them has a landmark every ten.
- Repeat the item description at the head of any continuation. A page of bare serial numbers with no indication of what they are is unusable.
- Cap what you print. Where a line carries more identifiers than a page can reasonably hold, print a count and reference an appendix, and say so on the line rather than silently truncating.
The fragment
Markup and the CSS it needs, and nothing else. It expects a document that already has a page rule and a base stylesheet, so paste it into one rather than opening it on its own.
<tr class="item-with-serials">
<td class="desc">
Pump assembly, 40mm
<div class="serials">
<span>AX-4471-0091</span><span>AX-4471-0092</span>
<span>AX-4471-0093</span><span>AX-4471-0094</span>
</div>
</td>
<td class="num">4</td>
<td class="num">1,240.00</td>
</tr>
<style>
.items tr { break-inside: avoid; }
/* the one row that must be allowed to break */
.items tr.item-with-serials { break-inside: auto; }
.serials {
columns: 4;
column-gap: 6mm;
margin-top: 3pt;
font-family: "IBM Plex Mono", ui-monospace, monospace;
font-size: 7.5pt;
line-height: 1.5;
font-variant-numeric: tabular-nums;
}
.serials span { display: block; white-space: nowrap; }
/* a landmark every tenth entry, for counting */
.serials span:nth-child(10n) { border-bottom: 0.3pt solid #ccc; }
</style>What breaks when it is built the obvious way
Applying the same atomic-row rule to every row in the table. It is correct for ninety-nine rows out of a hundred and catastrophic for the one carrying a long serial list, and the failure is invisible until a delivery with a large quantity comes through.
How to prove it survived pagination
Render a line with four hundred identifiers and confirm the list flows across pages with the description repeated, rather than being pushed whole onto a page it does not fit. Then read ten identifiers off the printed page and type them: if you lose your place, the grouping is missing.
Where it sits in a finished document
This page is one block. The document it belongs to has a page rule, a base stylesheet, a header and everything else around it, and repeating all of that here would make thirty pages that say the same thing. The packing slip template is a complete file with this block already in it, so take that and change the fragment rather than assembling one from parts. The property doing most of the work here is covered on its own page, with the support caveats that belong there rather than here.
Frequently asked
Will this fragment work on its own?
Not as a whole document. It has no page rule, no margins and no base type, because those belong to the document rather than to the block, and duplicating them in every fragment would mean thirty copies to keep in step. Paste it into a template that already has them.
Why does it look right in a browser and wrong in the PDF?
Because a browser window is one continuous surface and a document is a stack of fixed rectangles. Nothing in a scrolling view exercises a page boundary, so every break rule in the fragment is inert until the content is paginated. Render the real thing with enough content to cross two or three boundaries, then look.
Do I need a special option on the render request for this?
No. Everything on this page is CSS and markup, which is your side of the boundary. What the render has to give you is a real page size with real margins, and after that the layout is decided by the stylesheet.
Other parts of a document
The blocks that sit next to this one, and one from the next group along so you are not sealed inside a single kind of problem.
A dimensions and weight block that lines up across units
Length, width, height, gross and net weight and volume, printed for a package or a consignment, usually in two systems of units at once.
A meter reading table showing previous, current and consumption
Previous reading, current reading, the difference and the charge, printed for one or several meters on a utility-style bill.
A risk matrix that survives being printed in black and white
A likelihood by consequence grid with cells scored and coloured, used in method statements, assessments and permits.
A contact block where the long email address does not break the layout
Phone, email, reference number and website, usually set small under a name or in a footer, and usually the block that overflows first.
Packing slip, as a complete file
The whole document with this block already in place, ready to copy and change.
column-count in paged output
The property carrying the weight here, with its real support status.
Every part of a document
The full list, grouped by the kind of problem the block poses.
Paste the fragment into the playground inside a page rule and see what it does at a real page size. That is the only way any of this gets confirmed.