<anchor-size>
Newly availableSince 202688% of users
A function that retrieves the width or height of the anchor element. It's useful for making a popup or menu match the exact dimensions of the button that triggered it.
What's modern
From web-features, MDN's browser data and our snippets, checked dailyModernIn every major browser since January 2026. Widely available around July 2028.
The old way and the modern waySee the snippet: Dropdown width that matches its button →
Old way 8 lines
.select-menu {
position: absolute;
min-width: var(--button-width);
}
/* JS: measure the button and write its width */
const w = button.getBoundingClientRect().width;
menu.style.setProperty('--button-width', w + 'px');
/* then a ResizeObserver to redo it when the label or font changes */Modern 10 lines
.select-button {
anchor-name: --select;
}
.select-menu {
position: absolute;
position-anchor: --select;
position-area: bottom span-right;
min-width: anchor-size(width);
}
/* as wide as the button, no measuring */See how modern your own CSS is.Check your CSS →
Quick example
.tooltip {
/* Makes the tooltip exactly as wide as its anchor */
width: anchor-size(width);
position: absolute;
}Related snippet
Dropdown width that matches its buttonLayout →<anchor-size> browser support
BaselineNewly availableSince 2026 this feature works across the latest devices and browser versions. This feature might not work in older devices or browsers.Works in all modern browsers. May need a fallback for older browsers.
Usage88%of people can use this12% use a browser without it.
Browsers
125+
147+
26+
125+Mobile
125+Android
147+Android
26+iOS
Interop 2026 focus area. All major browsers are actively working to fix cross-browser inconsistencies for this feature in 2026. Learn more →