CSS Color Shifting, Anchor Positioning, and the Art of Responsive Video

Published on 13.01.2026

Color Shifting in CSS

TLDR: When animating between colors in CSS, the browser uses RGB color space which causes colors to become gray in the middle of transitions. Using filter: hue-rotate() instead provides smooth color shifts that maintain vibrancy throughout the animation.

Here's something that'll make you question everything you thought you knew about CSS color transitions. Josh Comeau discovered a fascinating limitation while building a particle effect - when you animate between two vibrant HSL colors, they become washed out and grayish in the middle. Why? Because browsers always do color interpolation in RGB, even when your colors are specified in HSL.

Think about it - you're animating from red to teal, both beautiful saturated colors. Mathematically, the browser is decreasing the red channel while increasing green and blue. Right in the middle, all three channels converge on the same value, producing... gray. No rational person would say the midpoint between red and teal is gray, but that's exactly what the math gives us.

The workaround is elegant: use filter: hue-rotate() instead of animating background-color. This filter actually rotates around the color wheel, maintaining saturation and lightness throughout the animation. You can even do multiple full rotations - something impossible with traditional color transitions since hsl(0deg) and hsl(360deg) resolve to identical RGB values.

For architects and teams, this is a perfect example of understanding the abstraction beneath your tools. CSS gives you HSL as a convenient syntax, but the rendering engine operates in RGB. When your mental model doesn't match the implementation, you get surprises. The lesson extends beyond colors - always question what's happening under the hood when your results don't match expectations.

Key takeaways:

  • Browser color interpolation happens in RGB regardless of how you specify colors
  • filter: hue-rotate() provides true hue rotation maintaining color vibrancy
  • Small random variations in animation timing prevent mechanical-looking synchronized effects
  • Understanding underlying implementations prevents debugging headaches

Link: Color Shifting in CSS


A Gentle Introduction to Anchor Positioning

TLDR: CSS anchor positioning lets you position elements relative to other elements without JavaScript. Using anchor-name and position-anchor properties, you can create responsive menus and tooltips that automatically adjust when viewport space runs out.

The new CSS anchor positioning API is one of those features that makes you wonder how we ever lived without it. Positioning a dropdown menu below an avatar used to require JavaScript to calculate positions. Now it's a few lines of CSS.

The mental model is straightforward: declare an anchor-name on your reference element (say, a profile button), then on your target element (the menu), set position-anchor to that name and give it absolute positioning. From there, you have two approaches for placement.

The position-area property thinks in terms of a 9-square grid with your anchor in the center. Want the menu bottom-center? Write block-end center. Need it to span beyond the grid when it's wider than the anchor? Use block-end span-inline-end. The syntax takes getting used to, but it's remarkably expressive.

Here's where it gets powerful: position-try lets you define fallback positions. On desktop, your menu drops down and extends right. On mobile where there's no room on the right? The browser automatically flips to extending left. No media queries, no JavaScript - just declarative CSS handling responsive behavior.

The alternative anchor() function works with inset properties instead of the grid model. You're essentially saying "align my left edge with the anchor's left edge" using left: anchor(left). More verbose but sometimes clearer for complex positioning needs.

For teams adopting this, remember to use logical properties (block-start, inline-end) rather than physical ones (top, right). It's more inclusive across writing modes and languages. Also note that browser support is still rolling out - test thoroughly and have fallbacks ready.

Key takeaways:

  • anchor-name and position-anchor establish the connection between elements
  • position-area uses a 9-square grid model for intuitive placement
  • position-try enables automatic responsive fallbacks without JavaScript
  • Always prefer logical properties over physical ones for internationalization

Tradeoffs:

  • Gain declarative responsive positioning but sacrifice fine-grained control over fallback timing
  • Using logical properties improves internationalization but increases learning curve for teams

Link: A gentle introduction to anchor positioning


Responsive Video is (Almost) Easy Now

TLDR: Self-hosted responsive video with vertical and horizontal variants is now practical thanks to WebM compression (60x smaller than MP4) and the <source> element's media query support. The main challenges are poster images and fullscreen switching, which still require some JavaScript.

This is a masterclass in web performance optimization disguised as a video embedding tutorial. The author needed to embed a 412MB MP4 on a homepage and got it down to 7MB as a WebM - that's 1/60th the size while still looking acceptable during playback.

The responsive video implementation itself is surprisingly elegant. The <source> element accepts a media attribute with aspect ratio queries. Vertical viewport? Serve the vertical video. Horizontal? Serve the horizontal one. The browser picks the first matching source, so order matters differently than CSS media queries.

Where things get complex is optimization. The author ended up with 84 <source> tags to cover different viewport sizes, pixel densities, and fullscreen scenarios. That sounds excessive until you consider the alternative - serving oversized videos to mobile users on spotty connections.

The gotchas are instructive. The browser won't automatically upgrade to higher resolution when you resize the window or go fullscreen - you need JavaScript to call video.load() and restore the timestamp. Poster images only accept a single URL despite videos supporting multiple sources, forcing either high-compression tricks or layered implementations. And preload="metadata" doesn't actually prevent video loading in some browsers.

For architects, this is a case study in progressive enhancement meeting real-world constraints. The ideal solution (automatic resolution switching, responsive posters) doesn't exist in the platform yet. The pragmatic solution involves understanding your audience's connection quality and building appropriate fallbacks. Sometimes 84 source tags is the right answer.

Key takeaways:

  • WebM achieves dramatically better compression than MP4 for web video
  • The <source> element's media attribute enables true responsive video
  • Fullscreen and resize handling requires JavaScript to reload video sources
  • Consider your audience's connection quality when deciding on resolution variants

Tradeoffs:

  • Self-hosting gives full control over compression and styling but requires managing multiple file variants
  • More source tags improve bandwidth efficiency but increase HTML complexity and maintenance burden
  • WebM compression saves bandwidth but sacrifices some browser compatibility (96% global support)

Link: Responsive video is (almost) easy now


Tail Lens – Browser Extension for Tailwind CSS

TLDR: Tail Lens is a Chrome extension that enables visual inspection and live editing of Tailwind CSS classes directly in the browser, with autocomplete, spacing guides, and support for custom configurations.

If you've ever bounced between VS Code and your browser trying to decide between gap-1 and gap-2, this tool directly addresses that workflow friction. Tail Lens lets you inspect Tailwind classes on any element and see intelligent alternatives - hover over a spacing utility and it shows you the adjacent options in the scale.

The search functionality previews any Tailwind class with the Alt key before applying, including classes from your custom config. It understands tailwind.config.js including themes and breakpoints, and supports both Tailwind v3 and v4's new CSS-based configuration.

For teams working with Tailwind, this fills a gap that browser DevTools don't address. Standard CSS inspection shows computed styles, but Tailwind's utility classes abstract away those values. Being able to quickly experiment with class alternatives without leaving the browser speeds up that iterative UI polish phase considerably.

Key takeaways:

  • Visual inspection of Tailwind classes with intelligent alternatives
  • Preview any class before applying with Alt key
  • Supports custom configurations and both Tailwind v3 and v4
  • One-time $29 purchase for lifetime access

Link: Tail Lens – Chrome Extension for Tailwind CSS


Tools Roundup

Logoipsum - Placeholder Logos

Need placeholder logos for mockups? Logoipsum offers 185 free SVG logos across styles like circular, geometric, logotype, and more. Copy or download directly - perfect for design prototypes before client branding is finalized.

Link: Logoipsum

Cap - Self-Hosted CAPTCHA

Cap is a privacy-first, self-hosted CAPTCHA alternative that's 250x smaller than hCaptcha (~20kb). It uses proof-of-work instead of visual puzzles, sends no telemetry, and supports invisible mode for background verification. Fully open-source under Apache 2.0.

For teams concerned about privacy compliance or third-party dependencies in authentication flows, this is worth evaluating. The proof-of-work approach means users don't waste time clicking traffic lights.

Link: Cap - Self-hosted CAPTCHA

Fabric - Self-Organizing Workspace

Fabric positions itself as an AI-powered "second brain" that automatically organizes notes, files, and links. Drop anything in and the AI understands content from colors in photos to concepts in documents. Features include voice notes, real-time collaboration, and natural language search across all your content.

Link: Fabric – your self-organizing workspace


This summary was compiled from Tailwind Weekly #201. The articles and tools featured represent the original authors' work and opinions.