Skip to content
Tutorials Center
My learning

Topics

CSS Reference ยท Positioning and Stacking

The position-try-fallbacks property

Reference for the CSS position-try-fallbacks property: list alternative placements such as flip-block or a named @position-try rule for anchored boxes.

The position-try-fallbacks property gives an anchored element a list of alternative positions to try when its default position would overflow its containing block, usually the viewport. The browser tests them in order and uses the first one that fits; if none fits, it keeps the original.

Each entry can be a tactic such as flip-block, a position-area value, or the name of an @position-try rule that you define yourself. The shorthand position-try combines this property with position-try-order.

CSS
.menu {
  position-area: bottom;
  position-try-fallbacks: flip-block;
}

Try it

Flip above when there is no room below

The anchor sits close to the bottom edge, so there is no room below it. The flip-block fallback moves the menu above the anchor. Where anchor positioning is not supported, the menu stays at its normal position.

Syntax

CSS
position-try-fallbacks: none | [ [ <dashed-ident> || <try-tactic> ] | <position-area> ]#;

/* <try-tactic> = flip-block || flip-inline || flip-start */

position-try-fallbacks: flip-block, flip-inline;
position-try-fallbacks: --my-below, --my-above;
position-try-fallbacks: top, bottom;
  • Initial value: none
  • Applies to: absolutely positioned boxes
  • Inherited: no
  • Animatable: no (discrete)
  • Computed value: as specified

Values

Value Description
none No fallbacks; the box stays where it is.
flip-block Mirror the position along the block axis (above becomes below in horizontal text).
flip-inline Mirror along the inline axis (left becomes right in left-to-right text).
flip-start Swap the start-side properties, effectively diagonal mirroring.
<dashed-ident> The name of an @position-try rule with alternative offsets, margins, sizes or position-area.
<position-area> A position-area value used directly as a fallback.

Usage notes

  • Order matters. Put the most preferred alternative first, since the first one that fits wins.
  • Tactics can combine. flip-block flip-inline mirrors on both axes in one entry.
  • Named rules let a fallback change more than position, for example a smaller max-width when flipped.
  • It never scrolls or resizes the box by itself. Make sure the content is allowed to wrap or use max-width.
  • Related: use position-visibility to hide the box once the anchor scrolls out of view.

Browser support

Part of CSS anchor positioning: Chromium browsers support it from version 128 and Safari from version 26; other browsers are still catching up. The property was previously named position-try-options, which early versions used.