Position-area - CSS Property
Summary of characteristics of the position-area property
none | center | top | right | bottom | left | x-start | x-end | y-start | y-end | span | block-start | block-end | inline-start | inline-end | self-block-start | self-block-end | self-inline-start | self-inline-endnonePer grammar: serialization in the order of syntax.Syntax diagram of position-area.
position-area property.The links in the diagram provide more details about the values.
Download the diagram.
These values are the most common, but position-area accepts many others:
- Values related to the XY axes:
x-start,x-end,y-start, andy-end.
These can also be shortened tostartandend. In this case, the order of writing these values matters: vertical direction first, then horizontal direction. - Values starting with
span(examples:span-y-startorspan-left-top) that allow you to position the element spanning two cells. - Values that are sensitive to the writing mode depending on the language used for the anchor. Their name starts with
blockorinline:inline-start,block-end, etc. - Values that are sensitive to the writing mode depending on the language of the text set. Their names start with
self:self-inline-start,self-block-start, etc.
Description of the position-area property.
The property position-area is involved in the field of anchor positioning: positioning one element relative to another, which is called the anchor.
Specifically, it indicates in which cell(s) the element should be positioned. The cells are defined as follows, relative to the anchor:
top left | top center | top right |
center left | Ancre ⚓ center center | center right |
bottom left | bottom center | bottom right |
position-area handles both horizontal and vertical positioning. In this sense, it's a simpler solution than using the anchor() function,
but it's also a less precise one.
See also the page on the anchor-name property for a list of properties involved in anchor positioning, as well as a tutorial on the topic.
Language support.
For automatic adaptation to the language used, choose the values whose name starts with block or inline.
You can also adapt to the language of the placed text by using the properties whose name starts with self.
topleftrightbottomValues for position-area.
- position-area: none;
The element is not positioned relative to an anchor. The positioning is done according to the
positionproperty, either relative to the page (absolute) or relative to the viewport (fixed). - position-area: top; position-area: right; position-area: bottom; position-area: left;
With one of these four values, the element positions itself on the cell above, to the right, below, or to the left of the anchor.
⚓toprightbottomleftcenter - position-area: top left; position-area: top right; position-area: bottom left; position-area: bottom right;
By specifying two values, you can position the element in one of the cells. The first value sets the vertical position. The second sets the horizontal position, but the order of the values doesn't matter since the names aren't ambiguous. Note that the value
center centeroverlays the positioned content in the middle of the anchor.
If only one value is given, the second is set tocenter.⚓top lefttop centertop rightcenter rightcenter leftcenter centerbottom rightbottom centerbottom left - position-area: y-start x-start; position-area: y-start x-end; position-area: y-end x-start; position-area: y-end x-end;
Values can be expressed along the X and Y axes, and they don't depend on the language. These are values whose names start with
xory.
Values likex-centerandy-centerdon't exist; we just use the usualcentervalue.
Again, the order of the values doesn't matter because the names aren't ambiguous.⚓y-start x-starty-start centery-start x-endcenter x-startcenter x-endy-end x-starty-end centery-end x-endcenter center - position-area: start start; position-area: start end; position-area: end start; position-area: end end;
The values can also be
startorend. In this case, the first value relates to positioning in the block direction, the second in the inline direction, and the order matters because the termsstartandendalone don't let you tell if we're talking about vertical or horizontal alignment.⚓start startstart centerstart endcenter startcenter centercenter endend startend endend center - position-area: self-block-start self-inline-start; position-area: self-block-start self-inline-end; position-area: self-block-end self-inline-start; position-area: self-block-end self-inline-end;
These two values are sensitive to the writing mode of the text placed (the one that receives the property
position-area).Writing mode:
⚓self-block-start
self-inline-startself-block-start
centerself-block-start
self-inline-endcenter
self-inline-endcenter
self-inline-endself-block-end
self-inline-startself-block-end
centerself-block-end
self-inline-end - position-area: top span-left;
The word
span-, which prefixes any term you've seen before, exceptcenter, means the positioned element should span two cells.span-allindicates that the text spans the three cells on the indicated side. For example,span-all toppositions the element over the three cells above the anchor.spancan be combined with physical values, XY values, or logical values.⚓top
span-lefttop
span-rightbottom
span-leftbottom
span-rightspan-top
left
span-all
right
- position-area: initial; (
none) position-area: inherit; position-area: revert; position-area: revert-layer; position-area: revert-rule; position-area: unset;Common values are presented on these pages:
initial,inherit,revert,revert-layer,revert-rule,unset.
Animation of the position-area property.
The animation of position-area is subtle: a sudden jump from one value to another, which is normal since the property doesn't accept numerical values.
Access the position-area property via a program
With Javascript, change the value of position-area.
In JavaScript, here's how to change the value of position-area. You can see that JavaScript offers a syntax using the typical CSS notation,
in kebab-case (a dash to separate words), and another syntax using the camel-case notation (a capital letter to separate words).

let el = document.getElementById('id');
el.style['position-area'] = 'left top';
// or
let el = document.getElementById('id');
el.style.positionArea = 'left top';
With Javascript, read the value of position-area.
The property must have been applied directly to the element itself via its HTML style attribute, and not through a CSS selector.

let el = document.getElementById('id');
let value = el.style['position-area'];
// or
let el = document.getElementById('id');
let value = el.style.positionArea;
With Javascript, read the computed value of position-area.
The computed value is the one that results from taking into account any inherited values. If not, it’s the initial value of the property, but in any case, the computed value is defined.

let el = document.getElementById('id');
let value = window.getComputedStyle(el).getPropertyValue('position-area');
With JQuery, read or change the value of position-area.
JQuery is a Javascript library that often allows shorter syntax than Javascript itself.

// Read the value:
$('#id').prop('position-area');
// Write the value:
$('#id').prop('position-area', 'left top');
$('#id').prop('{position-area': 'left top'});
With JQuery, read the computed value of position-area.

let value = $('#id').css('position-area');
Other code examples.
You can find more examples of Javascript and JQuery code on the page Javascript and CSS.
Test it yourself.
The buttons below apply the entered value to the position-area property and then show either the value as it was applied, or the computed value.
This second option lets you see how the value of position-area is stored (serialized). In the case of position-area, there aren’t big
differences unless you enter an incorrect value; in that case, the assigned value is empty, while the computed value is the initial value of the
property (none).
Simulator.
Not all of the values accepted by position-area are available in the simulator; only the main ones are listed.
text
Browsers compatibility with position-area.
The position-area property is well recognized by all current browsers. All values are handled correctly.
position-area property which indicates where the element should be positioned relative to the anchor.Notes:
(1) Samsung Internet does not support the position-anchor property with the value normal.anchor-visibility property.
(2) Android browser does not support the position-anchor property with the value normal.
It also doesn't fully support the anchor-visibility property.
(3) Doesn't fully support the anchor-visibility property.
(4) Firefox does not allow animation of the anchor() and anchor-size() functions.
It does not fully support the anchor-visibility property.
(5) Opera does not support the position-anchor property with the value normal.
It also doesn't fully support the anchor-visibility property.
positioning
position-areaproperty
Browsers on computers :
Mobile browsers :
Outdated or marginal browsers :

Internet Explorer

UC Browser pour Androïd

Opéra Mobile

QQ Browser

Baidu Browser

Samsung Internet

Androïd Brower

Chrome

Chrome pour Androïd

Edge

Firefox

Firefox pour Androïd

KaiOS Browser

Opéra

Safari

Safari sur IOS

Opéra mini
Historic of the position-area property.
-
CSS Anchor Positioning - Level 1
Absolute positioning relative to the page or screen can prove to be limited when you want to position an element relative to another.
This specification describes the properties necessary to achieve this, as well as the functionsanchor()andanchor-size()that allow you to set the position and dimensions of an element based on another.
It also describes how to test several positioning possibilities to adapt to the context, particularly to the state of the page scrolling.Regardingposition-areaFirst description of the propertyposition-areathat positions an element relative to its anchor.June 29, 2023Working Draft.
Voir aussi, à propos des positionnement par ancrage.
Anchor positioning is a fairly complex specification; all the properties, functions, and guidelines related to the subject are grouped in CSS Anchor Positioning, and listed below.
Properties:
anchor-name.position-try-fallbacks and position-try-order.position-try-fallbacks.


