CSS Anchor Positioning has a significant gotcha: the anchor element must be fully laid out before the element anchored to it. This means DOM order matters more than many developers realize, and you can't freely place anchored elements anywhere in the DOM. The safest approach is to make the anchor and positioned element siblings with the anchor appearing first in the DOM. The post also touches on the Inset-Modified Containing Block (IMCB) concept and links to helpful resources like anchor-tool.com and articles by Temani Afif and James Stuckey Weber. The author argues CSS should address this footgun in future iterations.
5 Comments
Sort: