CSS position-area Property

The CSS position-area property specifies where an absolutely positioned element should appear relative to its default anchor.

It is part of CSS Anchor Positioning and provides a convenient way to place tooltips, menus, labels, and other floating elements above, below, beside, or overlapping an anchor. Instead of calculating coordinates manually, you select an area around the anchor using physical or logical positioning keywords.

position-area Syntax

The position-area property accepts the keyword none or one or two positioning keywords that identify an area relative to the default anchor.

Basic Syntax

selector {
  position-area: bottom;
}

Common Values

.tooltip {
  position-area: top;
}
.tooltip {
  position-area: bottom;
}
.tooltip {
  position-area: left;
}
.tooltip {
  position-area: right;
}
.tooltip {
  position-area: center;
}
.tooltip {
  position-area: bottom right;
}

Logical Values

.tooltip {
  position-area: block-end;
}
.tooltip {
  position-area: inline-start;
}
.tooltip {
  position-area: block-end inline-end;
}

Spanning Values

.tooltip {
  position-area: span-all;
}
.tooltip {
  position-area: span-top;
}
.tooltip {
  position-area: span-bottom;
}

CSS-Wide Keywords

.tooltip {
  position-area: initial;
}
.tooltip {
  position-area: inherit;
}
.tooltip {
  position-area: unset;
}
.tooltip {
  position-area: revert;
}
.tooltip {
  position-area: revert-layer;
}

When the value is none, the property does not select an anchor-relative position area.

Property Values

The available keywords describe areas in a three-by-three grid formed around the anchor. The center row and column overlap the anchor, while the surrounding areas lie outside its edges.

Value Description
none Does not select an anchor-relative position area. This is the initial value.
top Selects the area above the anchor, spanning its horizontal alignment region.
bottom Selects the area below the anchor, spanning its horizontal alignment region.
left Selects the area to the left of the anchor.
right Selects the area to the right of the anchor.
center Selects the center region overlapping the anchor along the specified axis.
start Selects the start region on the relevant axis, based on the containing block's writing mode and direction.
end Selects the end region on the relevant axis.
block-start Selects the block-start side of the anchor.
block-end Selects the block-end side of the anchor.
inline-start Selects the inline-start side of the anchor.
inline-end Selects the inline-end side of the anchor.
self-block-start Selects the block-start side according to the positioned element's own writing mode.
self-block-end Selects the block-end side according to the positioned element's own writing mode.
self-inline-start Selects the inline-start side according to the positioned element's own writing mode.
self-inline-end Selects the inline-end side according to the positioned element's own writing mode.
span-all Spans all three regions along the applicable axis.
span-top, span-bottom Span the center region and the specified physical vertical side.
span-left, span-right Span the center region and the specified physical horizontal side.
span-start, span-end Span the center region and the logical start or end side.
span-block-start, span-block-end Span the center region and the corresponding logical block side.
span-inline-start, span-inline-end Span the center region and the corresponding logical inline side.
initial Resets the property to none.
inherit Uses the computed value from the parent element.
unset Resets the property to none because it is not inherited.
revert Reverts the property according to CSS cascade origin rules.
revert-layer Reverts the property according to CSS cascade layer rules.

Not every pair of keywords is valid. When two keywords are used, they must identify compatible regions along different axes.

Property Characteristics

Characteristic Value
Initial value none
Inherited No
Applies to Absolutely positioned elements
Computed value As specified
Animation type Discrete
Percentages Not applicable

Valid Values

.tooltip {
  position-area: bottom;
}
.menu {
  position-area: bottom left;
}
.label {
  position-area: block-start;
}
.popup {
  position-area: span-all;
}

Invalid Values

.tooltip {
  position-area: 20px;
}
.tooltip {
  position-area: above;
}
.tooltip {
  position-area: bottom top;
}
.tooltip {
  position-area: bottom right left;
}
.tooltip {
  position-area: bottom 10px;
}

The property uses supported positioning keywords rather than lengths, arbitrary directions, or more than two area keywords.

How It Works

CSS Anchor Positioning divides the space around an anchor into regions that can be selected using position-area.

The Anchor Grid

Imagine two horizontal lines extending from the anchor's top and bottom edges and two vertical lines extending from its left and right edges. These lines divide the positioning space into nine regions.

Browser Result
top left
top
top right
left
ANCHOR
right
bottom left
bottom
bottom right

This simplified diagram shows the basic placement regions. Single-keyword values can span multiple cells, while two-keyword values select more specific areas.

Selecting an Area

.tooltip {
  position-area: bottom;
}

The browser uses the region below the anchor as the tooltip's positioning area.

Alignment Within the Area

The browser also determines how the positioned element is aligned within its selected area. Alignment properties and margins can adjust the result.

The Default Anchor

The selected area is calculated relative to the element's default anchor, which can be established using position-anchor or an implicit anchor relationship.

Important Distinction

The position-anchor property selects the anchor, while position-area selects the area in which the positioned element is laid out.

Establishing an Anchor Relationship

Before using position-area, establish a default anchor for the absolutely positioned element.

Step 1: Name the Anchor

.help-button {
  anchor-name: --help-anchor;
}

Step 2: Reference the Anchor

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
}

Step 3: Select the Position Area

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
}

The tooltip is now associated with the named anchor and placed in the area below it.

Complete HTML Structure

<div class="help-container">
  <button class="help-button" type="button">Help</button>
  <div class="tooltip">Helpful information</div>
</div>

Implicit Anchors

Some HTML relationships, including certain popover invoker relationships, can establish an implicit anchor. In those cases, an explicit position-anchor declaration may not be necessary.

Important Consideration

Anchor names must match, and the named element must be an eligible anchor under the CSS Anchor Positioning rules.

Single-Keyword Positioning

Single-keyword values provide straightforward placement around an anchor.

Above the Anchor

.tooltip {
  position-area: top;
}

Below the Anchor

.tooltip {
  position-area: bottom;
}

Left of the Anchor

.tooltip {
  position-area: left;
}

Right of the Anchor

.tooltip {
  position-area: right;
}

Centered on the Anchor

.tooltip {
  position-area: center;
}

The center value selects the central anchor region along both axes, allowing the positioned element to overlap the anchor.

Important Consideration

Single-keyword values are useful when the desired placement is simply above, below, beside, or centered over an anchor.

Two-Keyword Positioning

Two-keyword values select a more specific position area by combining compatible vertical and horizontal regions.

Upper-Left Area

.tooltip {
  position-area: top left;
}

Upper-Right Area

.tooltip {
  position-area: top right;
}

Lower-Left Area

.tooltip {
  position-area: bottom left;
}

Lower-Right Area

.tooltip {
  position-area: bottom right;
}

Combining Center With a Side

.tooltip {
  position-area: center right;
}

This selects the center row and the region to the right of the anchor.

Keyword Order

Compatible physical keywords can be written in either order when their axes are unambiguous.

.tooltip {
  position-area: bottom right;
}
.tooltip {
  position-area: right bottom;
}

Important Consideration

Two keywords must describe compatible axes. For example, top bottom is invalid because both keywords describe the vertical axis.

Logical Positioning Values

Logical values allow anchor placement to follow the writing mode and text direction rather than fixed physical sides.

Block-End Positioning

.tooltip {
  position-area: block-end;
}

In a typical horizontal, left-to-right writing mode, block-end corresponds to the bottom side.

Block-Start Positioning

.tooltip {
  position-area: block-start;
}

In a typical horizontal writing mode, this corresponds to the top side.

Inline-End Positioning

.tooltip {
  position-area: inline-end;
}

In left-to-right horizontal text, inline-end corresponds to the right side. In right-to-left text, it corresponds to the left side.

Combining Logical Directions

.tooltip {
  position-area: block-end inline-end;
}

This selects the area at the block-end and inline-end sides of the anchor.

Self-Relative Values

.tooltip {
  position-area: self-block-end;
}

Self-relative values use the positioned element's own writing mode to determine the corresponding direction.

Important Consideration

Logical positioning is especially useful for multilingual interfaces and layouts that support different writing directions.

Spanning Position Areas

Spanning keywords select regions that extend across more than one section of the anchor grid.

Span All Regions

.tooltip {
  position-area: span-all;
}

The span-all value spans all three regions along the applicable axis.

Span the Top and Center Regions

.tooltip {
  position-area: span-top;
}

Span the Bottom and Center Regions

.tooltip {
  position-area: span-bottom;
}

Span the Left and Center Regions

.tooltip {
  position-area: span-left;
}

Span the Right and Center Regions

.tooltip {
  position-area: span-right;
}

Combining Spanning Keywords

.tooltip {
  position-area: span-bottom span-right;
}

Compatible spanning keywords can select an area extending across multiple regions along both axes.

Logical Spanning

.tooltip {
  position-area: span-block-end;
}

Logical spanning values follow the corresponding writing-mode direction.

Important Consideration

Spanning values are useful when a positioned element needs more available space or must overlap part of its anchor's region.

Alignment and Spacing

After selecting a position area, alignment properties and margins can adjust the positioned element's placement within that area.

Adding Space Below an Anchor

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
  margin-top: 8px;
}

Horizontal Alignment

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
  justify-self: center;
}

The justify-self property can control alignment within the selected positioning area.

Vertical Alignment

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: right;
  align-self: center;
}

Using place-self

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
  place-self: start center;
}

The place-self shorthand sets align-self and justify-self together.

Sizing to the Anchor

.menu {
  position: absolute;
  position-anchor: --menu-anchor;
  position-area: bottom;
  width: anchor-size(width);
}

The anchor-size() function can make a dropdown menu match the width of its anchor.

Important Consideration

The selected position area establishes the available region. Alignment, margins, and sizing then determine how the element fits within it.

Position Fallbacks

A preferred position area may not fit when an anchor is close to a viewport or containing block boundary. CSS Anchor Positioning provides fallback mechanisms that can try alternative placements.

Preferred Placement

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
}

Flip to the Opposite Block Side

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
  position-try-fallbacks: flip-block;
}

The browser can try the opposite block-side placement when the preferred placement does not fit.

Flip Along the Inline Axis

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: right;
  position-try-fallbacks: flip-inline;
}

Multiple Fallback Options

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
  position-try-fallbacks: flip-block, flip-inline;
}

The browser can evaluate the specified fallback options when the preferred placement overflows.

Using position-try

.tooltip {
  position: absolute;
  position-anchor: --help-anchor;
  position-area: bottom;
  position-try: flip-block;
}

The position-try shorthand provides another way to configure position fallback behavior.

Fallback for Unsupported Browsers

.container {
  position: relative;
}
.tooltip {
  position: absolute;
  top: 100%;
  left: 0;
}
@supports (position-area: bottom) and (position-anchor: --help-anchor) {
  .tooltip {
    position-anchor: --help-anchor;
    position-area: bottom;
    top: auto;
    left: auto;
  }
}

Conventional absolute positioning provides a fallback, while supported browsers can use anchor-relative placement.

Important Consideration

Position fallbacks help with available space, but they do not replace the need to test anchored content in different viewport sizes and scrolling conditions.

position-area Example

The following example places a tooltip below a named anchor using position-area: bottom.

HTML Example

<div class="position-area-demo">
  <button class="demo-button" type="button">Help Button</button>
  <div class="demo-tooltip">Tooltip positioned below the anchor</div>
</div>

CSS Example

.position-area-demo {
  position: relative;
  min-height: 180px;
  padding: 25px;
  text-align: center;
  border: 2px solid #94a3b8;
  background-color: #f1f5f9;
}
.position-area-demo .demo-button {
  anchor-name: --demo-anchor;
  padding: 10px 18px;
  border: 0;
  background-color: #2563eb;
  color: #ffffff;
}
.position-area-demo .demo-tooltip {
  position: absolute;
  position-anchor: --demo-anchor;
  position-area: bottom;
  margin-top: 10px;
  padding: 10px 14px;
  background-color: #1e293b;
  color: #ffffff;
}
@supports not ((position-anchor: --demo-anchor) and (position-area: bottom)) {
  .position-area-demo .demo-tooltip {
    top: 85px;
    left: 50%;
    transform: translateX(-50%);
  }
}
Browser Result
Tooltip positioned below the anchor

The button declares the anchor name, and the tooltip references it using position-anchor. The position-area: bottom declaration selects the region below the button.

Moving the Tooltip Above the Anchor

.position-area-demo .demo-tooltip {
  position-area: top;
  margin-top: 0;
  margin-bottom: 10px;
}

Changing the area to top places the tooltip above the anchor in supporting browsers.

Moving the Tooltip to the Right

.position-area-demo .demo-tooltip {
  position-area: right;
  margin-top: 0;
  margin-left: 10px;
}

The right value selects the area beside the anchor.

Accessibility Considerations

The position-area property changes visual placement but does not establish semantic or keyboard relationships between elements.

Maintain Logical Source Order

Keep related controls and content in a meaningful HTML order, even when CSS positions them elsewhere visually.

Use Appropriate Semantics

Tooltips, menus, and popovers should use suitable HTML elements and accessibility attributes for their intended behavior.

Preserve Keyboard Access

Interactive anchored elements must remain reachable and operable using a keyboard.

Avoid Obscuring Content

Positioned elements should not cover important controls or prevent users from reading surrounding content.

Support Zoom and Text Resizing

Test anchor-relative positioning at increased zoom levels and with larger text.

Provide Visible Focus

Ensure focus indicators remain visible when anchored overlays are displayed.

Important Consideration

CSS controls where anchored content appears. Accessible interaction behavior must be implemented separately.

Common Mistakes

Forgetting to Establish an Anchor

.tooltip {
  position: absolute;
  position-area: bottom;
}

Without an eligible default anchor, the property cannot establish the intended anchor-relative area.

Omitting Absolute Positioning

.tooltip {
  position-anchor: --help-anchor;
  position-area: bottom;
}

For typical anchored tooltips, use position: absolute.

Using Unsupported Direction Words

.tooltip {
  position-area: above;
}

Use top instead of above.

Combining Conflicting Keywords

.tooltip {
  position-area: top bottom;
}

Both keywords describe the same axis, so this combination is invalid.

Using Lengths as Position Areas

.tooltip {
  position-area: bottom 10px;
}

Use a supported position-area value and a separate margin or other positioning property for spacing.

Confusing position-area With position-anchor

position-anchor identifies the default anchor. position-area selects an area relative to that anchor.

Expecting Automatic Overflow Prevention

Setting a position area does not guarantee that the element will fit inside the viewport. Use position fallback properties when appropriate.

Ignoring Writing Modes

Physical keywords do not change direction with writing mode. Use logical values when placement should adapt to text direction.

Assuming Universal Browser Support

CSS Anchor Positioning is a newer feature. Test support and provide fallbacks when necessary.

Important Considerations

Keep the following points in mind when using position-area:

  • It selects an area relative to an absolutely positioned element's default anchor.
  • Its initial value is none.
  • The property is not inherited.
  • It accepts supported area keywords or none.
  • One or two compatible positioning keywords can be used.
  • Physical values include top, bottom, left, and right.
  • The center value selects the central anchor region.
  • Two-keyword values can select specific corner areas.
  • Logical values adapt to writing modes and directions.
  • Self-relative values use the positioned element's writing mode.
  • Spanning keywords select areas covering multiple regions.
  • An eligible default anchor is required for anchor-relative placement.
  • Use anchor-name to name an anchor.
  • Use position-anchor to select a named default anchor.
  • Some HTML relationships can establish implicit anchors.
  • The property does not create an anchor by itself.
  • Margins can add spacing between the anchor and positioned element.
  • Alignment properties can adjust placement within the selected area.
  • anchor-size() can size an element relative to its anchor.
  • Position fallback properties can try alternative placements when space is limited.
  • Anchor positioning may be affected by scrolling and clipping.
  • Browser support varies across CSS Anchor Positioning features.
  • Provide conventional positioning fallbacks when needed.
  • Test layouts near viewport boundaries.
  • Test anchored content with different writing directions.
  • Ensure positioned elements do not obscure important controls.
  • Maintain logical HTML source order and accessible interactions.

Browser Support

The CSS position-area property has Limited availability and is not supported consistently across all widely used browsers.

It belongs to the CSS Anchor Positioning feature set. Support for related properties such as position-anchor, position-try, and position-visibility may also vary by browser and version.

For current compatibility information, visit Can I Use? and search for position-area.

Use feature queries and conventional positioning fallbacks when supporting browsers without CSS Anchor Positioning.

Specifications

The position-area property is defined in CSS Anchor Positioning Module Level 1.

CSS Anchor Positioning Module Level 1

The specification defines position-area keywords, anchor-relative regions, and their interaction with positioned layout and alignment.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: position-area