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
- Basic styling for presentations, ebooks, or pdfs
- Use it as a base for your next website (roll your own typography etc)
- Preview styles in the
specimen
file - Uses plain CSS (
-css-variables
) and thelessc
compiler to chunk files1
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. Or, perhaps you're an author publishing an ebook?
Write it down with Markdown, then convert with the app of your choice:
- Pandoc if you know what a terminal is,
- Marked if you prefer GUIs,
file -> print
a website or save as a PDF with your browser.
Think about print first; add the finesse for screen-based devices later:
@media all
for BOTH screen and print (use often)@media screen
to ADD css for screen only@media print
to 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-ui
fonts (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-BaselineGrid
class for vertical rythmn.- Aim to keep grid-level items divisible by
8
or4
- You may need to adjust your font's
--line-height
andmargin-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 init
npm install badlydrawnrob/print-first-css --save-dev
npm 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-variables
in: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