Modern CSS
The CSS references I keep going back to while building this site, from color and dark mode to motion and layout.
25 of 25 links
Color
oklch.com
Pick OKLCH colors and see which ones fit in sRGB and P3.
OKLCH in CSS: why we moved from RGB and HSL
Evil Martians on why OKLCH makes palettes easier to reason about than RGB or HSL.
light-dark()
One color for each color scheme, picked by the element's color-scheme.
WCAG: Contrast (minimum)
The 4.5:1 and 3:1 rules for text, and what counts as large text.
Dark mode
Your dark mode toggle is broken
Kilian Valkhof argues a theme toggle needs a way back to the system setting.
Dark mode toggles: two states are enough
Lea Verou makes the case for two visible states, the system theme and its opposite.
The best dark mode toggle is probably none
Lea Verou's follow-up, on why most sites don't need a toggle at all.
The case for tri-state dark mode toggles
Bramus argues for showing all three states, system, light and dark.
Building a theme switch component
Adam Argyle builds an accessible light and dark switch, step by step.
Motion
scroll-driven-animations.style
Demos and tools for animations driven by scrolling instead of time.
CSS scroll-driven animations
The reference for animation-timeline, scroll() and view().
View Transition API
Animated changes between two states of a page, or between pages.
Unlocking view transitions in SvelteKit
How to run SvelteKit's navigations inside a view transition with onNavigate.
prefers-reduced-motion
The media feature that tells you someone asked for less motion.
Layout
Container queries
Styles that respond to the size of a container instead of the viewport.
grid-template-areas
Name the areas of a grid and place items by name.
auto-fill vs auto-fit
The two ways repeat() fills a row, and why auto-fit stretches the cards.
position sticky
An element that scrolls with the page until it reaches an edge, then stays.
Foundations
A Modern CSS Reset
Josh Comeau's small reset, with the reason for every line.
@layer
Cascade layers, where the order of the layers beats specificity.
Using CSS custom properties
Variables in CSS, how they inherit and how var() falls back.
Open Props
Ready-made design tokens as custom properties, the base of this site's tokens.
Inspiration
nerdy.dev
Adam Argyle's site. This site's theme toggle reveal started here.
brittanychiang.com
The sticky intro beside scrolling sections that this site's landing borrows.
julibe.com
Where the colored scrollbar, the detaching header and the footer hint came from.