- Remember that Print First CSS is a bare-bones approach ...
- It is not a framework! A child theme takes on that responsibility.
Who on earth prints these days? I do! Quite often actually: notes to edit, website reference, a CV, perhaps an eBook ... Remember: CSS sucks to write so less is more.
A solid base for simple layouts such as PDFs, books, websites; acts as a starter theme with solid typography. Makes for pleasurable reading when you need to print out on paper.
Only the essentials here, folks:
- No fluff, no grid system (just helpful
--spacingvariables) - Basic styling for presentations, ebooks, or pdfs (with
--colorfor text) - Can be extended and used as a child theme for any
@media print/screencontent - Has a
specimenfile to preview styles - Uses css variables) and the
lessccompiler to chunk files1
Everything is motion these days, but lets go back to our roots!
Print is often a second citizen these days, but it's useful! You might need to rattle off presentations, write a proposal, build a CV, or share ideas quickly. Perhaps you're a budding author publishing an ebook!
Write it with Markdown, convert with the app of your choice:
- Pandoc if you know what a terminal is,
- Marked if you prefer GUIs,
- Save as a PDF with your browser (using
print-first-css) withfile -> print.
Think about print first; add the finesse for screen-based devices later:
@media allfor BOTH screen and print (use often)@media screento ADD css for screen only@media printto REMOVE screen css for print (use sparingly)@media (orientation: portrait)(orlandscape) may come in handy too.
The method isn't suitable for every job, but for printable media, it's much better for a long blog post, or complex user interfaces!
Uses your device
system-uifonts (Android and iOS)
Typography heavily influenced by Material Design — all typography aligns to a 4dp grid, with default --font-size of 16dp.
Inline code and pre blocks use font-size: inherit. It seems most devices have the monospace font with a larger x-height than the regular font. It's best if you find a monospace font that's similar in height to your default, but here's a small fix for if it isn't.
.gl-BaselineGridclass for vertical rythmn.- Aim to keep grid-level items divisible by
8or4- You may need to adjust your font's
--line-heightandmargin-bottom
Everything aligns to an 8dp baseline grid (double the typography baseline). A vertical rythmn is nice in theory, difficult in practice for web-based styles. Try to keep the box-model aligned and consider align-items: baseline if using flexbox.
Remember, "Perfect is the enemy of good" (Voltaire) so sometimes it's best to just eyeball it; does it feel right?
Just do the enough thing!1
- You'll have Node installed
- Create your repo and
cd ./project npm initnpm install badlydrawnrob/print-first-css --save-devnpm run build
To upgrade, check the release notes first, then npm upgrade.
Print First CSS is licensed under the MIT Open Source License
There's been a bunch of inspirations over the years, but mostly thanks to @cbracco (Cardinal CSS) and Material Design.
Footnotes
-
You can
@import (less)files into your own project and override the--css-variablesin:root. Recompile with NPM (npm run build) and you're ready to do the enough thing. Follow the don't make me think principles for styles and UI and try to be consistent with your code. ↩ ↩2