Menu

Chrome rewrites our text colours when it prints, and the heading is the one it gets wrong
📰

Chrome rewrites our text colours when it prints, and the heading is the one it gets wrong

DEV Community: css·Daniel Pertu·4 days ago
#s5fif67u
#devtocss#devto#dev#print#paper
Reading 0:00
15s threshold

PubTrivia is a quiz night app, and quiz nights involve paper. People print the running order, the scoresheets, the answer sheets. So it is slightly embarrassing that our stylesheet contains this many rules about printing:

$ for k in '@media print' '@page' 'break-inside' 'page-break' 'orphans' 'widows' 'print-color-adjust' ; do printf "%-20s %s\n" "$k" "$(grep -o " $k " css_*.css | wc -l)" done @media print 0 @page 0 break-inside 0 page-break 0 orphans 0 widows 0 print-color-adjust 0

Enter fullscreen mode

Exit fullscreen mode

Zero, in 107,598 bytes across our two stylesheets. I spent an evening finding out what that actually produces, using Page.printToPDF over CDP rather than guessing.

Nothing changes under print media

First the control. Emulating print media and re-reading computed styles on eight pages:

await page . cdp ( "Emulation.setEmulatedMedia" , { media : "print" } ) ;

Enter fullscreen mode

Exit fullscreen mode

matchMedia('print').matches goes true, and then nothing moves.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.