Last updated on

Today I Learned


Introduction

I’ve noticed that the longer I write code, the more I bump into things I “already know” but never really understood. They work, I use them, and then one day a tiny behavior or detail makes me stop and dig deeper. Most of those discoveries never make it past a browser tab or a passing thought — which is a waste, because that’s where the real learning hides.

“Today I Learned” doesn’t always mean brand new. Sometimes it’s something I’ve used for years but never stopped to read the spec, question the behavior, or write it down properly. This series is my way of slowing down just enough to capture those quiet “oh, that’s why” moments — not because they’re groundbreaking, but because they’re worth remembering.

And of course, not everything here comes from experience. Some posts start with me realizing I actually don’t know how something works, then digging until it finally makes sense — and writing it down before I forget again.

Day 0

  1. [CSS] accent-color

Browsers that support accent-color currently apply it to the following HTML elements:

  • <input type="checkbox">
  • <input type="radio">
  • <input type="range">
  • <progress>
  1. [CSS] :active, :focus, :focus-visible, :focus-within
  • The :focus-within CSS pseudo-class matches an element if the element or any of its descendants are focused. In other words, it represents an element that is itself matched by the :focus pseudo-class or has a descendant that is matched by :focus. (This includes descendants in shadow trees.)
  • The :active CSS pseudo-class represents an element (such as a button) that is being activated by the user. When using a mouse, “activation” typically starts when the user presses down the primary mouse button.

  • The :focus CSS pseudo-class represents an element (such as a form input) that has received focus. It is generally triggered when the user clicks or taps on an element or selects it with the keyboard’s kbk>Tab key.

  • The :focus-visible pseudo-class applies while an element matches the :focus pseudo-class and the UA (User Agent) determines via heuristics that the focus should be made evident on the element. (Many browsers show a “focus ring” by default in this case.)

  • The difference between :focus and :focus-visible lies in intent, not capability. Both target elements that currently have focus, but :focus-visible activates only when the browser determines the user needs a visible cue—usually when navigating with a keyboard or assistive technology. In contrast, :focus triggers for any focused element, regardless of how it was reached. This means :focus is best for behavior and logic (like showing a dropdown when an input gains focus), while :focus-visible is for visual indicators that help non-mouse users track their position without cluttering the interface for pointer