Working Draft · css-position

CSS Positioned Layout

13 properties, 1 selector defined by this specification, all known to at least one browser .

Each feature in detail

bottom

Property Baseline: widely availablesince January 2018 Modern CSS: Anchor positioning

MDN The bottom CSS property participates in setting the vertical position of a positioned element. This inset property has no effect on non-positioned elements.

Live preview Example from MDN
.example-container {
  border: 0.75em solid;
  padding: 0.75em;
  text-align: left;
  position: relative;
  width: 100%;
  min-height: 200px;
}

#example-element {
  background-color: #264653;
  border: 4px solid #ffb500;
  color: white;
  position: absolute;
  width: 140px;
  height: 60px;
}

Syntax

auto | <length-percentage> | <anchor()> | <anchor-size()>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
refer to size of containing block; see prose
Computed value
the keyword auto or a computed <length-percentage> value
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting bottom
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

inset

Property Baseline: widely availablesince March 2024 Modern CSS: Anchor positioning

MDN The inset CSS shorthand property corresponds to the top, right, bottom, and/or left properties. It has the same multi-value syntax of the margin shorthand.

Live preview Example from MDN
.example-container {
  border: 0.75em solid #ad1457;
  padding: 0.75em;
  text-align: left;
  position: relative;
  width: 100%;
  min-height: 200px;
}

#example-element {
  background-color: #07136c;
  border: 6px solid #ffa000;
  color: white;
  position: absolute;
  inset: 0;
}

Syntax

<'top'>{1,4}

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
see individual properties
Computed value
see individual properties
Canonical order
per grammar
Animation type
by computed value type
Longhands
top, right, bottom, left

Browser support

First browser version supporting inset
Chrome 87
Edge 87
Firefox 66
Safari 14.1
Chrome Android 87
Safari iOS 14.5

First version with support, from MDN browser-compat-data.

inset-block

Property Baseline: widely availablesince March 2024 Modern CSS: Anchor positioning

MDN The inset-block CSS shorthand property defines the logical block start and end offsets of an element, which maps to physical offsets depending on the element's writing mode, directionality, and text orientation. It corresponds to the top and bottom, or right and left properties depending on the values defined for writing-mode, direction, and text-orientation.

Live preview Example from MDN
.example-container {
  border: 0.75em solid #ad1457;
  padding: 0.75em;
  text-align: left;
  position: relative;
  width: 100%;
  min-height: 200px;
}

#example-element {
  background-color: #07136c;
  border: 6px solid #ffa000;
  color: white;
  position: absolute;
  inset: 0;
}

Syntax

<'top'>{1,2}

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
see individual properties
Computed value
see individual properties
Canonical order
per grammar
Animation type
by computed value type
Longhands
inset-block-start, inset-block-end

Browser support

First browser version supporting inset-block
Chrome 87
Edge 87
Firefox 63
Safari 14.1
Chrome Android 87
Safari iOS 14.5

First version with support, from MDN browser-compat-data.

inset-block-end

Property Baseline: widely availablesince March 2024 Modern CSS: Anchor positioning

MDN The inset-block-end CSS property defines the logical block end offset of an element, which maps to a physical inset depending on the element's writing mode, directionality, and text orientation. It corresponds to the top, right, bottom, or left property depending on the values defined for writing-mode, direction, and text-orientation.

Live preview Example from MDN
#example-element {
  border: 0.75em solid;
  padding: 0.75em;
  position: relative;
  width: 100%;
  min-height: 200px;
  unicode-bidi: bidi-override;
}

#abspos {
  background-color: yellow;
  color: black;
  border: 3px solid red;
  position: absolute;
  inset-block-end: 20px;
  inline-size: 140px;
  min-block-size: 200px;
}

Syntax

auto | <length-percentage>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
refer to size of containing block; see prose
Computed value
the keyword auto or a computed <length-percentage> value
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting inset-block-end
Chrome 87
Edge 87
Firefox 63
Safari 14.1
Chrome Android 87
Safari iOS 14.5

First version with support, from MDN browser-compat-data.

inset-block-start

Property Baseline: widely availablesince March 2024 Modern CSS: Anchor positioning

MDN The inset-block-start CSS property defines the logical block start offset of an element, which maps to a physical inset depending on the element's writing mode, directionality, and text orientation. It corresponds to the top, right, bottom, or left property depending on the values defined for writing-mode, direction, and text-orientation.

Live preview Example from MDN
#example-element {
  border: 0.75em solid;
  padding: 0.75em;
  position: relative;
  width: 100%;
  min-height: 200px;
  unicode-bidi: bidi-override;
}

#abspos {
  background-color: yellow;
  color: black;
  border: 3px solid red;
  position: absolute;
  inset-block-start: 50px;
  inline-size: 140px;
}

Syntax

auto | <length-percentage>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
refer to size of containing block; see prose
Computed value
the keyword auto or a computed <length-percentage> value
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting inset-block-start
Chrome 87
Edge 87
Firefox 63
Safari 14.1
Chrome Android 87
Safari iOS 14.5

First version with support, from MDN browser-compat-data.

inset-inline

Property Baseline: widely availablesince March 2024 Modern CSS: Anchor positioning

MDN The inset-inline CSS shorthand property defines the logical start and end offsets of an element in the inline direction, which maps to physical offsets depending on the element's writing mode, directionality, and text orientation. It corresponds to the top and bottom, or right and left properties depending on the values defined for writing-mode, direction, and text-orientation.

Live preview Example from MDN
.example-container {
  border: 0.75em solid #ad1457;
  padding: 0.75em;
  text-align: left;
  position: relative;
  width: 100%;
  min-height: 200px;
}

#example-element {
  background-color: #07136c;
  border: 6px solid #ffa000;
  color: white;
  position: absolute;
  inset: 0;
}

Syntax

<'top'>{1,2}

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
see individual properties
Computed value
see individual properties
Canonical order
per grammar
Animation type
by computed value type
Longhands
inset-inline-start, inset-inline-end

Browser support

First browser version supporting inset-inline
Chrome 87
Edge 87
Firefox 63
Safari 14.1
Chrome Android 87
Safari iOS 14.5

First version with support, from MDN browser-compat-data.

inset-inline-end

Property Baseline: widely availablesince March 2024 Modern CSS: Anchor positioning

MDN The inset-inline-end CSS property defines the logical inline end inset of an element, which maps to a physical offset depending on the element's writing mode, directionality, and text orientation. It corresponds to the top, right, bottom, or left property depending on the values defined for writing-mode, direction, and text-orientation.

Live preview Example from MDN
#example-element {
  border: 0.75em solid;
  padding: 0.75em;
  position: relative;
  width: 100%;
  min-height: 200px;
  unicode-bidi: bidi-override;
}

#abspos {
  background-color: yellow;
  color: black;
  border: 3px solid red;
  position: absolute;
  inset-inline-end: 50px;
  inline-size: 140px;
  min-block-size: 80px;
}

Syntax

auto | <length-percentage>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
refer to size of containing block; see prose
Computed value
the keyword auto or a computed <length-percentage> value
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting inset-inline-end
Chrome 87
Edge 87
Firefox 63
Safari 14.1
Chrome Android 87
Safari iOS 14.5

First version with support, from MDN browser-compat-data.

inset-inline-start

Property Baseline: widely availablesince March 2024 Modern CSS: Anchor positioning

MDN The inset-inline-start CSS property defines the logical inline start inset of an element, which maps to a physical offset depending on the element's writing mode, directionality, and text orientation. It corresponds to the top, right, bottom, or left property depending on the values defined for writing-mode, direction, and text-orientation.

Live preview Example from MDN
#example-element {
  border: 0.75em solid;
  padding: 0.75em;
  position: relative;
  width: 100%;
  min-height: 200px;
  unicode-bidi: bidi-override;
}

#abspos {
  background-color: yellow;
  color: black;
  border: 3px solid red;
  position: absolute;
  inset-inline-start: 50px;
  inline-size: 140px;
  min-block-size: 80px;
}

Syntax

auto | <length-percentage>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
refer to size of containing block; see prose
Computed value
the keyword auto or a computed <length-percentage> value
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting inset-inline-start
Chrome 87
Edge 87
Firefox 63
Safari 14.1
Chrome Android 87
Safari iOS 14.5

First version with support, from MDN browser-compat-data.

left

Property Baseline: widely availablesince January 2018 Modern CSS: Anchor positioning

MDN The left CSS property participates in specifying the horizontal position of a positioned element. This inset property has no effect on non-positioned elements.

Live preview Example from MDN
.example-container {
  border: 0.75em solid;
  padding: 0.75em;
  text-align: left;
  position: relative;
  width: 100%;
  min-height: 200px;
}

#example-element {
  background-color: #264653;
  border: 4px solid #ffb500;
  color: white;
  position: absolute;
  width: 140px;
  height: 60px;
}

Syntax

auto | <length-percentage> | <anchor()> | <anchor-size()>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
refer to size of containing block; see prose
Computed value
the keyword auto or a computed <length-percentage> value
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting left
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

overlay

Property Limited availability Experimental Modern CSS: overlay

MDN The overlay CSS property specifies whether an element appearing in the top layer (for example, a shown popover or modal <dialog> element) is actually rendered in the top layer. This property is only relevant within a list of transition-property values, and only if allow-discrete is set as the transition-behavior.

Live preview Example from MDN
html {
  font-family: "Helvetica", "Arial", sans-serif;
}

[popover]:popover-open {
  opacity: 1;
  transform: scaleX(1);
}

[popover] {
  font-size: 1.2rem;
  padding: 10px;

  /* Final state of the exit animation */
  opacity: 0;
  transform: scaleX(0);

  transition:
    opacity 0.7s,
    transform 0.7s,
    overlay 0.7s allow-discrete,
    display 0.7s allow-discrete;
  /* Equivalent to
  transition: all 0.7s allow-discrete; */
}

/* Needs to be included after the previous [popover]:popover-open
   rule to take effect, as the specificity is the same */
@starting-style {
  [popover]:popover-open {
    opacity: 0;
    transform: scaleX(0);
  }
}

/* Transition for the popover's backdrop */

[popover]::backdrop {
  background-color: transparent;
  transition:
    display 0.7s allow-discrete,
    overlay 0.7s allow-discrete,
    background-color 0.7s;
  /* Equivalent to
  transition: all 0.7s allow-discrete; */
}

[popover]:popover-open::backdrop {
  background-color: rgb(0 0 0 / 25%);
}

/* Nesting selectors (&) cannot represent pseudo-elements, so this 
   starting-style rule cannot be nested. */

@starting-style {
  [popover]:popover-open::backdrop {
    background-color: transparent;
  }
}

Syntax

none | auto

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
none
Applies to
all elements
Inherited
no
Percentages
n/a
Computed value
as specified
Canonical order
per grammar
Animation type
see prose

Browser support

First browser version supporting overlay
Chrome 117
Edge 117
Firefox No
Safari No
Chrome Android 117
Safari iOS No

First version with support, from MDN browser-compat-data.

position

Property Baseline: widely availablesince January 2018

MDN The position CSS property sets how an element is positioned in a document. The top, right, bottom, and left physical properties and the inset-block-start, inset-block-end, inset-inline-start, and inset-inline-end flow-relative logical properties can be used to determine the final location of positioned elements.

Live preview Example from MDN
section {
  align-items: flex-start;
  overflow: auto;
}

.box {
  background-color: rgb(0 0 255 / 0.2);
  border: 3px solid blue;
  float: left;
  width: 65px;
  height: 65px;
}

.box + .box {
  margin-left: 10px;
}

.clear {
  clear: both;
  padding-top: 1em;
}

#example-element-container {
  position: relative;
  text-align: left;
}

#example-element {
  background-color: yellow;
  border: 3px solid red;
  z-index: 1;
}

Syntax

static | relative | absolute | sticky | fixed | <running()>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
static
Applies to
all elements except table-column-group and table-column
Inherited
no
Percentages
N/A
Computed value
specified keyword
Canonical order
per grammar
Animation type
discrete

Browser support

First browser version supporting position
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

top

Property Baseline: widely availablesince January 2018 Modern CSS: Anchor positioning

MDN The top CSS property sets the vertical position of a positioned element. This inset property has no effect on non-positioned elements.

Live preview Example from MDN
.example-container {
  border: 0.75em solid;
  padding: 0.75em;
  text-align: left;
  position: relative;
  width: 100%;
  min-height: 200px;
}

#example-element {
  background-color: #264653;
  border: 4px solid #ffb500;
  color: white;
  position: absolute;
  width: 140px;
  height: 60px;
}

Syntax

auto | <length-percentage> | <anchor()> | <anchor-size()>

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Definition

Initial
auto
Applies to
positioned elements
Inherited
no
Percentages
refer to size of containing block; see prose
Computed value
the keyword auto or a computed <length-percentage> value
Canonical order
per grammar
Animation type
by computed value type

Browser support

First browser version supporting top
Chrome 1
Edge 12
Firefox 1
Safari 1
Chrome Android 18
Safari iOS 1

First version with support, from MDN browser-compat-data.

::backdrop

Selector Baseline: widely availablesince September 2024 Modern CSS: Fullscreen APIModern CSS: Popover

Spec Each element rendered in the top layer has a ::backdrop pseudo-element, for which it is the originating element.

MDN The ::backdrop CSS pseudo-element is a box the size of the viewport, which is rendered immediately beneath any element being presented in the top layer.

Live preview Example from MDN
button {
  font-size: 1.2rem;
  padding: 5px 15px;
}

dialog::backdrop {
  background-color: salmon;
}

Syntax

::backdrop

Formal grammar from the specification, as webref extracts it: the latest level's definition, sometimes ahead of what browsers implement.

Browser support

First browser version supporting ::backdrop
Chrome 37
Edge 79
Firefox 47
Safari 15.4
Chrome Android 37
Safari iOS 15.4

First version with support, from MDN browser-compat-data.