Skip to main content

CSS anchor positioning

The CSS anchor positioning module defines features that allow you to tether elements together. Certain elements are defined as anchor elements; anchor-positioned elements can then have their size and position set based on the size and location of the anchor elements to which they are bound.

In addition, the specification provides CSS-only mechanisms to:

  • Specify a set of alternative positions for an anchored element; when the default rendering position causes it to overflow its containing block and/or be rendered offscreen, the browser will try rendering the anchored element in the alternative positions instead.
  • Declare conditions under which anchor-positioned elements should be hidden, in situations where it is not appropriate to tether them to anchor elements.

Reference

Properties

  • {{cssxref("anchor-name")}}
  • {{cssxref("position-anchor")}}
  • {{cssxref("position-area")}}
  • {{cssxref("position-try-fallbacks")}}
  • {{cssxref("position-try-order")}}
  • {{cssxref("position-try")}} shorthand
  • {{cssxref("position-visibility")}}

[!NOTE] The CSS anchor positioning module introduces the anchor-scope property that has not yet been implemented.

At-rules and descriptors

  • {{cssxref("@position-try")}}

Functions

Data types and values

HTML attributes

  • anchor {{non-standard_inline}}

Interfaces

  • {{domxref("CSSPositionTryDescriptors")}}
  • {{domxref("CSSPositionTryRule")}}
  • {{domxref("HTMLElement.anchorElement")}} {{non-standard_inline}}

Guides

  • Using CSS anchor positioning

    • : An introductory guide to fundamental anchor positioning concepts, including associating, positioning, and sizing elements relative to their anchor.
  • Handling overflow: try fallbacks and conditional hiding

    • : A guide to the mechanisms CSS anchor positioning provides to prevent anchor-positioned elements from overflowing their containing elements or the viewport, including position try fallback options and conditionally hiding elements.
  • CSS logical properties and values module:
    • {{cssxref("inset-block-start")}}
    • {{cssxref("inset-block-end")}}
    • {{cssxref("inset-inline-start")}}
    • {{cssxref("inset-inline-end")}}
    • {{cssxref("inset-block")}}
    • {{cssxref("inset-inline")}}
    • {{cssxref("inset")}} shorthand
    • {{cssxref("inline-size")}}
    • {{cssxref("min-block-size")}}
    • {{cssxref("min-inline-size")}}
    • {{cssxref("max-block-size")}}
    • {{cssxref("max-inline-size")}}
    • Inset properties glossary term
  • CSS positioned layout module:
    • {{cssxref("top")}}
    • {{cssxref("left")}}
    • {{cssxref("bottom")}}
    • {{cssxref("right")}}
  • CSS box model module:
    • {{cssxref("width")}}
    • {{cssxref("height")}}
    • {{cssxref("min-width")}}
    • {{cssxref("min-height")}}
    • {{cssxref("max-width")}}
    • {{cssxref("max-height")}}
    • {{cssxref("block-size")}}
  • CSS box alignment module:
    • {{cssxref("align-items")}}
    • {{cssxref("align-self")}}
    • {{cssxref("justify-items")}}
    • {{cssxref("justify-self")}}
    • {{cssxref("place-items")}}
    • {{cssxref("place-self")}}

Specifications

See also