HTML anchor Global Attribute
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.
Description
#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
idof the element to use as the anchor.
Example
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.
Desktop





Tablets & Mobile





