Favorites

HTML anchor Global Attribute

anchor
HTML Global AttributeThis global attribute is not supported by modern browsers.
Updated 22nd November 2026

The anchor attribute linked a positioned element to an anchor element for CSS anchor positioning. It is non-standard: use anchor-name and position-anchor.

☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee

Description

This is an experimental attribute. It is non-standard and only available in Chrome behind the #enable-experimental-web-platform-features flag. Use the CSS anchor-name and position-anchor properties instead.

The anchor global attribute links a positioned element to an anchor element for CSS anchor positioning. Its value is the id of the anchor element, and it gives the positioned element an implicit anchor, so it can be placed with position-area or the anchor() function without naming the anchor in CSS.

<button id="menu-button">Menu</button>
<div anchor="menu-button" class="menu">...</div>

The attribute was proposed together with CSS anchor positioning but was not added to the HTML standard. The supported way to tether elements is to give the anchor an anchor-name and the positioned element a matching position-anchor. A popover opened by a popovertarget button, or an element opened by a commandfor button, also gets an implicit anchor automatically.

Syntax

<element anchor="id">

Values

  • idThe id of the element to use as the anchor.

Example

<style>
#anchor-btn { anchor-name: --menu; }
.menu {
position: absolute;
position-anchor: --menu;
position-area: bottom;
margin: 0;
padding: 10px;
border: 1px solid;
}
</style>
<p>This example uses the standard CSS properties, which work in all browsers that support anchor positioning:</p>
<button id="anchor-btn">Menu</button>
<div class="menu" anchor="anchor-btn">Positioned below the button</div>
Open in editor

Browser Support

The following information will show you the current browser support for the HTML anchor global attribute. Hover over a browser icon to see the version that first introduced support for this HTML global attribute.

This global attribute is not supported by modern browsers.

Desktop

Chrome
Edge
Firefox
Opera
Safari

Tablets & Mobile

Chrome Android
Firefox Android
Opera Android
Safari iOS
Samsung Internet
Android WebView
-
Supported Unknown Not supported
☕
Enjoying this site?

Help keep it running with a small coffee donation. Every bit of support is appreciated!

Buy us a coffee