Marks on the page / Callout box
A callout box that survives a page break and a monochrome printer
A boxed note set apart from the body text, carrying a warning, a definition or an aside.
Why this block is harder than it looks
A callout is a box with a background, and both halves are fragile in print. The background is dropped by many print settings, taking any light text with it and leaving a box that reads as an empty frame. The box itself can be taller than the space left on the page, and a callout split across a break loses the visual containment that made it a callout in the first place. The third failure is subtler: a document with four kinds of callout in four colours conveys nothing in greyscale, because all four become the same grey.
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.
- Dark text on a light tint, never light text on a dark fill. The tint can disappear and the text still has to be readable.
- Carry the meaning in a left border weight or a label rather than in the fill colour, so the kinds of callout remain distinguishable in greyscale.
- Set break-inside: avoid on short callouts and accept them moving to the next page, and allow long ones to break rather than being forced whole.
- Set print-color-adjust: exact so the tint prints where the pipeline permits it.
- Give it real padding, at least 4mm, so the text is not touching the border. A tight box reads as a table cell.
- Keep the label short and in the box rather than above it, so a callout that does break still carries its label on the first part.
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.
<aside class="callout warn">
<p class="label">Before you start</p>
<p>Confirm the isolation is in place and locked off. Work must not begin
until the permit has been signed by the person in charge.</p>
</aside>
<style>
.callout {
break-inside: avoid;
margin: 10pt 0;
padding: 5mm; /* real padding, not a table cell */
background: #f3f1ea;
border-left: 2.5pt solid #999; /* meaning carried by the border */
print-color-adjust: exact;
-webkit-print-color-adjust: exact;
font-size: 9pt;
line-height: 1.45;
}
.callout p { margin: 0; }
.callout .label {
margin-bottom: 3pt;
font-size: 7.5pt;
letter-spacing: 0.08em;
text-transform: uppercase;
color: #555;
}
/* kinds distinguished by border weight, which survives greyscale */
.callout.warn { border-left-width: 4pt; border-left-color: #d23a1d; }
.callout.note { border-left-width: 1.5pt; }
</style>What breaks when it is built the obvious way
White text on a dark fill. Print backgrounds off and the callout becomes an empty rectangle with invisible text in it, which is a worse outcome than having no callout at all because the space is still occupied.
How to prove it survived pagination
Print with backgrounds disabled and confirm every callout is still fully readable and still distinguishable from the body text. Then photocopy it and confirm you can still tell a warning from a note.
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 hot work permit 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 margin note aligned to the paragraph it belongs to
A short note set in the outer margin beside the text it refers to, used for cross-references, dates and editorial comments.
A pull quote that does not orphan the paragraph it came from
A short extract set large and apart from the body, used to break up a long document and signal what matters in it.
Fold marks and punch hole guides that stay clear of the content
Faint marks at the page edge showing where a sheet will be folded or punched, so nothing important lands under a crease or a hole.
Keeping an image and its caption on the same page
An image with a numbered caption beneath it, which has to stay with its caption and has to be referable from the text that mentions it.
Hot work permit, as a complete file
The whole document with this block already in place, ready to copy and change.
print-color-adjust 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.