惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

人人都是产品经理
人人都是产品经理
aimingoo的专栏
aimingoo的专栏
Y
Y Combinator Blog
B
Blog
D
Docker
C
Check Point Blog
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
F
Fortinet All Blogs
Stack Overflow Blog
Stack Overflow Blog
Recent Announcements
Recent Announcements
MongoDB | Blog
MongoDB | Blog
WordPress大学
WordPress大学
Jina AI
Jina AI
罗磊的独立博客
月光博客
月光博客
博客园 - Franky
L
LangChain Blog
H
Help Net Security
Google DeepMind News
Google DeepMind News
Microsoft Security Blog
Microsoft Security Blog
小众软件
小众软件
T
Tailwind CSS Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻

Terence Eden’s Blog

Book Review: How to Build a Space Station by Jonathan Morrison Theatre Review: The School for Wives - at Riverside Studios How to get a DOI for your blog posts [RSS Club] Sorry for breaking your feed readers! Esoteric HTML - ismap vs CSS The expectations of privacy in driverless cars ActivityPub - How to send an updated user profile to Mastodon and the Fediverse [RSS Club] Sneak peek at new DOI functionality Put an AV test at the start of your slides ActivityPub - Is it worth defending against replay attacks and message/signature time skew? The purpose of DNS is to spread scams Book Review: The Passing of the Dragon and Other Stories by Ken Liu A reasonably practical guide to validating RFC 9421 HTTP Signatures for ActivityPub in PHP Book Review: ActivityPub by Evan Prodromou Review: Ruined Theatre's A Midsummer Night's Dream ActivityBot is the recipient of an NLnet grant! A simple "copy this code" button in JavaScript "iT woRKs BeTter in THe aPp!!" Book Review: The Infinite Sadness of Small Appliances by Glenn Dixon Gadget Review: Thermal Master P3 Macro Lens Theatre Review: Cats at Regent's Park Open Air Theatre Why do audience members choose specific shows at the Edinburgh Fringe? Book Review: An Immense World - How Animal Senses Reveal the Hidden Realms Around Us by Ed Yong Asymmetric Agents And then the men with guns tell you to do it anyway Thoughts on visiting the Edinburgh Fringe as a newbie Book Review: Slags by Emma Jane Unsworth Edinburgh Fringe: Target Audience Edinburgh Fringe: Stand-up Philosophy Edinburgh Fringe: Waiting for Wonka
Death to px, long live ch!
Terence Eden · 2026-08-23 · via Terence Eden’s Blog

Pixels are a lie. Even if you think you're drawing something with "pixel perfect" accuracy, your monitor is lying to you. There is no grid of platonically perfect squares.

In CSS, pixels are a double lie:

Note that 1px doesn't necessarily equal one physical device pixel. On HD displays, it may span multiple physical pixels. Similarly, 1cm in CSS often doesn't correspond to one hundredth of SI meter. On a large TV screen, it typically is longer than that. The lengths are perceptual: 16px looks roughly the same on a phone, laptop, or TV screen at typical viewing distance.

This blog is primarily text based. I want the width of the text to be readable for the average human. So, rather than setting the main width to be a percentage of the screen, I set it based on character width using the ch unit - which isn't exactly a character but good enough for my purposes:

 CSS--width-content: min(75ch, 100%);

main {
   max-width: var(--width-content);
}

When it comes to padding and margins, the same is true. If I want a gap around an element, I want that gap to be in proportion to the text inside it.

For widths, it makes sense to re-use the ch unit. I want the gap to be in proportion to the text.

But for height, perhaps it doesn't make sense to express vertical distance on character width? In which case the ex unit can be used. It is the size of a typical lower-case letter.

Just like my idea to eliminate CSS classes from my HTML, it's possible to go too far with this. I haven't changed every reference from em to ch, I'm just experimenting to see if it works.

There's nothing wrong, immoral, or evil about using px - or any other measure unit. Using ch and ex fit with my particular proclivities.