Skip to content
tezvyn:

CSS

275 bites tagged CSS — interview questions with model answers, and 60-second explainers.

Design Systems2 min read

Forced Colors Mode: When the User Overrides Your Palette

Forced Colors Mode is an accessibility feature where the browser overrides your site's colors with a user-defined, high-contrast palette. This ensures readability for users who depend on it. The footgun is disabling it and making your UI invisible.

Design Systems2 min read

Style Encapsulation with Shadow DOM

Shadow DOM creates a private DOM tree for a component, acting like a one-way mirror for CSS. This prevents style collisions in complex UIs, ensuring a button's CSS doesn't break a header.

Design Systems2 min read

LCH Color: More Vivid, Predictable UI Colors

LCH is a color space that aligns with human perception. It fixes HSL's broken lightness and unlocks 50% more vivid colors on modern screens. The footgun: LCH hue angles don't match HSL's; 0° is magenta, not red, so you can't just swap them.

Design Systems2 min read

Token Tiers: From Raw Values to Component Properties

Token tiers layer your design system from abstract to concrete: raw values become semantic names, which then style components. This lets you change a core color and see it update everywhere.

Design Systems2 min read

CSS clamp(): Fluid Sizing Without Media Queries

CSS clamp() sets guardrails for a value, letting it scale fluidly but never going outside a min/max bound. It's ideal for responsive typography, allowing font-size to grow with the viewport. The footgun: the preferred value is ignored at extreme screen sizes.

Design Systems2 min read

Vertical Rhythm: A Formula for Consistent Spacing

Vertical rhythm is a system for consistent spacing derived from your body text's line height. Use this calculated unit between all elements—paragraphs, lists, and after headings—to create harmony.

Design Systems2 min read

Typographic Scale: A System for Consistent Text

A typographic scale is a predefined set of font sizes and line heights that creates visual harmony. Design systems use it for consistent, readable text across devices. The footgun is adding one-off font sizes, which breaks the system's rhythm and consistency.

CSS & Design Systems2 min read

Component Usage Guidelines: The Manual for Your Design System

Usage guidelines are the instruction manual for your design system, ensuring consistency. They prevent developers from guessing button states and designers from stretching logos.

CSS & Design Systems2 min read

Atomic CSS: Styling with Single-Purpose Utilities

Atomic CSS builds interfaces with tiny, single-purpose classes directly in your HTML, like using LEGO bricks for styling. It's the core of frameworks like Tailwind CSS, letting you build UIs without writing custom CSS. The footgun is creating unreadable HTML.

CSS & Design Systems2 min read

Design System Governance: Preventing UI Chaos

A design system governance model defines the rules for evolving your UI library, preventing a free-for-all of conflicting changes. It dictates how new components are proposed and approved.

CSS & Design Systems2 min read

Atomic Design: Building UIs from the Smallest Parts

Atomic Design treats UIs as thoughtful hierarchies, building interfaces from the smallest parts up. This methodology helps create robust design systems for rolling out consistent UIs faster across countless devices. The footgun is seeing it as a rigid process.

CSS & Design Systems2 min read

Sass Control Directives: Logic in Your Stylesheets

Sass control directives bring programming logic—if/else, loops—into your CSS preprocessor. Use them to generate component variations or utility classes without repetitive code.

CSS & Design Systems2 min read

Source Maps: Debug Your Compiled CSS

Source maps are a decoder ring for your browser's dev tools, translating minified CSS back to the original SCSS or LESS files you wrote. This lets you debug styles in your source code, not the unreadable compressed output.

CSS & Design Systems2 min read

PostCSS Preset Env: Write Future CSS Today

postcss-preset-env is like Babel for CSS, transpiling modern syntax into code older browsers understand. Use it to write features like nesting or `color-mix()` today. The footgun: it only polyfills Stage 2+ features by default; you must opt-in for more.

CSS & Design Systems2 min read

Mobile-First Design: Start Small, Then Scale Up

Mobile-first design means building for the smallest screen first, then enhancing for larger ones. This ensures a solid baseline experience on phones, where most users are. The footgun is thinking it's just CSS, not a content-first strategy.

CSS & Design Systems2 min read

CSS Combinators: Targeting by Relationship

CSS combinators target elements by their DOM relationship, not just class or ID. They let you select an element inside another (`div p`) or right next to one (`h2 + p`). This is key for styling nested menus or spacing adjacent items.

CSS & Design Systems2 min read

CSS Houdini: Extending the CSS Engine

CSS Houdini gives developers low-level access to the browser's rendering engine, letting you write your own CSS features. Use it to polyfill new CSS or define type-safe custom properties with @property, preventing invalid values from being silently ignored.

CSS & Design Systems2 min read

CSS Anchor Positioning: Beyond the Containing Block

CSS Anchor Positioning lets you tether an element to any other element, not just its parent. Use it for popovers or tooltips that automatically reposition to stay in view. The footgun is forgetting to explicitly name your anchor with `anchor-name`.

CSS & Design Systems2 min read

View Transitions API: Animate Between DOM States

The View Transitions API lets the browser handle complex animations between page states. It simplifies transitions in Single-Page Apps and, for the first time, enables them for Multi-Page Apps. The main footgun is forgetting it's a progressive enhancement.

CSS & Design Systems2 min read

CSS Masking: Using Stencils for Web Elements

CSS masking is like a stencil for your elements. You provide a shape, and only the parts of the element under the stencil's cutout are visible. Use it for non-rectangular shapes, like text cutouts.

CSS & Design Systems2 min read

color-mix(): CSS's Native Color Blender

color-mix() lets you blend two colors directly in CSS, like mixing paint. Use it to generate theme variations, like hover states, from a base color. The chosen color space (e.g., srgb, oklch) dramatically changes the result, so always specify it.

CSS & Design Systems2 min read

CSS Scroll Snap: Guiding User Scrolling

CSS Scroll Snap turns a free-scrolling container into a slideshow, guiding users to land perfectly on predefined points. It's ideal for image carousels or full-page sections where partially visible elements look sloppy.

CSS & Design Systems2 min read

The Popover API: Native Tooltips and Menus

The Popover API creates tooltips and menus with just HTML, placing them in a top layer above all other content without `z-index` hacks. Use it for action menus or notifications.

CSS & Design Systems2 min read

Fix Ragged Text Lines with `text-wrap: balance`

Fix awkward text wrapping in headings. `text-wrap: balance` tells the browser to make each line roughly the same length, improving readability. Use it for short text blocks like titles, but know it's limited to a few lines due to performance costs.

Get CSS bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.