Learn CSS Visually - CSS explained one diagram at a time - flexbox, grid, the box model and more

static, relative, absolute, fixed, sticky: CSS Position Explained

By · Updated

Disclosure: this page contains Amazon affiliate links. As an Amazon Associate we earn from qualifying purchases, at no extra cost to you.

The usual one-line explanation of position: absolute is relative to the nearest positioned ancestor, and it leaves out the other ancestors that count too.

I came to this page as the researcher: on November 29, 2026 I read the W3C CSS Positioned Layout draft, MDN’s position and containing block pages and Can I use, then measured one 80 by 40 pixel box in Chrome 158 under all five values.

Three dates matter.

MDN says position: sticky has been available across browsers since July 2015.

The W3C draft that defines all five values is a Working Draft of 7 October 2025.

And two MDN pages list different ancestors as capturing a fixed box, so I tested those as well.

Position is the CSS property that decides where a box sits, and it has five values that each answer one question.

If you like a printed reference next to the keyboard, the CSS Visual Dictionary paperback on Amazon draws boxes and layout as pictures.

Short answer: position: static is the default and follows normal flow. relative offsets a box from its own spot and keeps that spot reserved. absolute leaves the flow and measures from the nearest positioned ancestor. fixed measures from the window. sticky acts like relative until scrolling pushes it against an edge, then holds there.

Five panels drawn to scale showing one 80 by 40 pixel blue box with top 20 pixels and left 30 pixels inside a 300 by 160 pixel card. Static leaves the box at 56, 76. Relative moves it to 86, 96 and leaves a dashed outline at 56, 76. Absolute inside a relative card puts it at 70, 80, with a dashed outline at 30, 20 showing where it would land with no positioned ancestor. Fixed puts it at 30, 20 in the window. Sticky holds it 20 pixels below the window top for 88 pixels of scrolling.
One box, top: 20px and left: 30px, under each of the five position values, measured in Chrome 158.

What the diagram shows, in plain text (a 300 x 160px card at page position 40, 60 with 16px padding, holding an 80 x 40px box, top: 20px; left: 30px):

What does the CSS position property do?

The position property chooses how a box is placed on the page, and top, right, bottom and left then offset it. Anything other than static makes the box a positioned box, which is what lets those four offsets work.

The W3C CSS Positioned Layout Module Level 3 (Working Draft, 7 October 2025) defines static in one line: The box is not a positioned box, and is laid out according to the rules of its parent formatting context.

MDN gives the same default in plainer words: top, right, bottom, left and z-index have no effect on a static element.

The five values split into two families. relative and sticky keep the box in the flow. absolute and fixed take it out, so nothing around it makes room.

Where does a box land under each position value?

A box with top: 20px; left: 30px lands somewhere different under each value, because each value measures from a different place. The table lists what we measured in Chrome 158 for the card in the diagram.

The five position values side by side — measured by Learn CSS Visually in Chrome 158 with getBoundingClientRect(), and checked against the W3C CSS Positioned Layout Module Level 3 and MDN’s position reference, November 29, 2026
ValueKeeps its space in the flow?Measured fromWhere our 80 x 40px box landedAlways starts a stacking context?
staticyesno offset: top and left are ignored56, 76no
relativeyes, at its old spotits own normal position86, 96no, only with a z-index value
absolutenopadding box of the nearest containing block70, 80 from a positioned card; 30, 20 with noneno, only with a z-index value
fixednothe window (viewport)30, 20, also after scrolling 100pxyes
stickyyes, at its old spotthe nearest scrolling ancestor, inside its parent56, 76 at rest; 20px below the window top while stuckyes

In one line: only relative and sticky leave a hole behind them, and only fixed and sticky always start a stacking context.

What is position: static?

Static is the default position of every element, so a box with no position declared follows normal flow and ignores offsets. You only write it to switch off another value, for example position: static inside a media query.

That explains the most common beginner message, “my top: 20px does nothing”: the box is still static. In our test the static box stayed at 56, 76 with top: 20px; left: 30px set.

What does position: relative do?

A relative box is laid out as if static, then shifted by its offsets. Nothing else on the page moves, and the space the box would have used stays reserved.

MDN puts it this way: The offset does not affect the position of any other elements; thus, the space given for the element in the page layout is the same as if position were static. In our test the box moved from 56, 76 to 86, 96 (30px right, 20px down).

The second job of relative matters more in practice: it turns the box into the reference point for absolute children, with no visible change at all. That is the habit explained in the section on absolute vs relative below.

What does position: absolute do?

An absolute box leaves the normal flow completely and is placed by its offsets, measured from its containing block. Its siblings and its parent behave as if it were not there.

The W3C draft says an absolute box is taken out of flow such that it has no impact on the size or position of its siblings and ancestors. MDN adds that no space is created for the element in the page layout.

In our test the card had position: relative, so the box landed at 70, 80: the card’s corner at 40, 60 plus the 30px and 20px offsets. Without a positioned ancestor, the same CSS put it at 30, 20 from the page’s corner, above the card entirely.

What does position: fixed do?

A fixed box is positioned against the window and stays in place while the page scrolls. It is the value behind sticky chat buttons, cookie bars and navbars that never leave the screen.

MDN says it is positioned relative to its initial containing block, which is the viewport in the case of visual media, and that this value always creates a new stacking context. In our test the box measured 30, 20 in the window both at scroll 0 and after scrolling 100px.

The viewport is only the default. A few ancestor properties take it over, as the containing block section below shows.

What does position: sticky do?

A sticky box scrolls like a normal box until it reaches the offset you set, then stays there until its parent scrolls out of view. You need at least one offset, usually top, for it to do anything.

The W3C draft says the offsets represent insets from the respective edges of the nearest scrollport, and that the box moves inward insofar as it can while its position box remains contained within its containing block.

That second half is the part people forget. Our card’s content area runs from 76px to 204px down the page, and the box is 40px tall, so with top: 20px it travels 204 — 76 — 40 = 88px while stuck. We measured it stuck at a scroll of 56px, still stuck at 144px, and moving again at 145px.

.card   { padding: 16px; }
.label  { position: sticky; top: 20px; }   /* sticks 20px below the window top */

What does position: absolute measure from?

An absolute box measures from the padding box of its containing block: the nearest ancestor with a position other than static, or one of a few other properties such as transform. If no ancestor qualifies, it measures from the initial containing block at the page’s corner.

Diagram of how to find the containing block of an absolutely positioned box. A blue absolute box sits inside a parent with position relative, inside a grandparent with no position, inside the html element. Three questions walk up the ancestors: is the position anything but static, is there a transform, translate, rotate, scale, perspective, filter, backdrop-filter or will-change on one of those, is there contain layout, paint, strict or content or content-visibility auto. Any yes makes that ancestor the containing block, measured from its padding box; all no answers end at the initial containing block at the page corner.
Walk up from the absolute box: the first ancestor that answers yes is the one it measures from.

The three questions in the diagram, in plain text:

  1. Does the ancestor have a position of relative, absolute, fixed or sticky?
  2. Does it have a transform, translate, rotate, scale, perspective, filter or backdrop-filter other than none, or a will-change that names one of them?
  3. Does it have contain set to layout, paint, strict or content, or content-visibility: auto?

MDN’s Containing block guide states the first rule: the containing block is formed by the edge of the padding box of the nearest ancestor element that has a position value other than static.

The padding box includes the padding but not the border. An absolute box with top: 0; left: 0 sits against the inside of the parent’s border, not on it.

If your absolute box ends up in the wrong place, work up the ancestors with those three questions. The match is usually a parent you styled long ago.

Which properties make an ancestor the containing block? Where the sources disagree

The sources give three different lists, so we tested every property in Chrome 158 with a fixed child. All of them except container-type pulled a fixed box away from the window and into the ancestor, 40px from the left edge plus the 30px offset.

Which ancestor properties capture a position: fixed child — compiled by Learn CSS Visually from the W3C CSS Positioned Layout Module Level 3, MDN’s position reference and MDN’s Containing block guide, plus our own Chrome 158 test, November 29, 2026
Ancestor propertyMDN Containing block guideMDN position pageChrome 158: did the fixed child follow the ancestor?
transform: translateX(0)yesyesyes (70, not 30, from the left)
filter: blur(0)yesyesyes
backdrop-filter: blur(1px)yesnot mentionedyes
contain: paintyesnot mentionedyes
contain: layoutyesnot mentionedyes
will-change: transformyesyesyes
perspectiveyes, with a note about browser inconsistenciesyesnot tested
container-type: inline-sizenot listednot listedno: stayed at 30, 20 in the window

The short version: MDN’s position page lists only transform, perspective, filter and will-change: transform, while its Containing block guide adds backdrop-filter, contain and content-visibility: auto. The W3C draft gives a non-exhaustive list that starts include transform, will-change, contain. Trust the longer list, and test the odd ones.

What is the difference between position absolute and relative?

A relative box stays in the flow, keeps its space and moves from its own spot. An absolute box leaves the flow, keeps no space and measures from a containing block. The two work as a pair: relative on the parent, absolute on the child.

Put position: relative on the parent and give no offsets, and nothing moves, but the parent becomes the reference for any absolute child. That is how a badge sits in a card’s corner with top: 8px; right: 8px.

.card  { position: relative; }               /* the reference point */
.badge { position: absolute; top: 8px; right: 8px; }

Our guide to centering a div uses the same pair with top: 50% and translate, one of its six methods.

What is the difference between position fixed and sticky?

A fixed box is always positioned against the window and leaves the flow, so it covers whatever is under it. A sticky box stays in the flow, scrolls normally, and only holds against an edge while its parent is on screen.

Here’s a moment almost every newbie knows: you write top: 20px, nothing moves, and you start doubting the browser. It is nearly always a static box. Once you see that offsets only work on positioned boxes, half the confusion on this page disappears.

That makes fixed right for a bar that must stay for the whole page, like a cookie notice. Sticky suits a table header or a section label that should stay only while its own section is visible.

Because a fixed box takes no space, the content under it needs padding or a margin equal to the bar’s height. A sticky bar needs neither, because it kept its place in the flow.

Both always start a stacking context, per MDN, so a z-index on them competes with the other layers of the page.

Why is my position: sticky not working?

A sticky box stops sticking for one of four reasons: no offset is set, an ancestor has an overflow value other than visible, the parent is only as tall as the box, or the box is a stretched flex or grid item. We built each one in Chrome 158 to check.

Four reasons position: sticky does nothing — tested by Learn CSS Visually in Chrome 158 and checked against MDN’s position reference and the W3C CSS Positioned Layout Module Level 3, November 29, 2026
CauseWhat we saw or what the source saysFix
No offset setMDN: if both insets of an axis are auto, the sticky value will behave as relativeadd top: 0 (or another offset)
An ancestor has overflow: hidden, auto or scrollIn a 600px tall wrapper with overflow: hidden, the box scrolled away with the page after a 300px scroll instead of stickingremove the overflow from the ancestors between the box and the scrolling area, or move it to a wrapper that is not an ancestor
The parent is as short as the boxIn a 40px tall parent holding a 40px box, the box had no room to travel and left with its parentgive the box a taller parent: it only sticks inside its containing block
The box is a stretched flex or grid itemA sticky sidebar in an 800px tall flex row was stretched to 800px, filled its container, and scrolled off; with align-self: flex-start and height: 100px it held at 20pxalign-self: flex-start (or start in grid) and a height shorter than the row

MDN explains the overflow cause: a sticky element sticks to its nearest ancestor that has a “scrolling mechanism” (created when overflow is hidden, scroll, auto or overlay), even if that ancestor isn’t the nearest actually scrolling ancestor.

The flex case is the one our tests surprised us with: the sidebar is a full-height box, so there is no room left for it to move. Our flexbox guide covers align-self and stretching.

Why did my parent shrink to nothing when I used position: absolute?

An absolute child takes no space in its parent, so a parent whose only child is absolute collapses to zero height. The W3C draft says it has no impact on the size or position of its siblings and ancestors.

The fix is to give the parent a height, or a min-height, because the child can no longer hold it open. If the child only needs to sit in a corner, put it in a parent that has other in-flow content too.

This also explains why an absolute box covers the text near it. Nothing in the layout knows it is there, which is why the content beside it needs its own padding. For the space left between normal blocks, see our guide to why margins collapse.

Does position: sticky work in every browser?

Yes, in every current browser. MDN marks sticky as Baseline: It’s been available across browsers since July 2015. Can I use shows 97.39% of users with support, on the page we read November 29, 2026.

Full support, Chrome
91 (partial support from 56)
Full support, Edge
91 (partial support from 16)
Full support, Firefox
59 (partial support from 32)
Full support, Safari on desktop
7.1 (partial support from 7)
Full support, Safari on iOS
8 (partial support from 6)

For older Safari, MDN’s example includes a -webkit-sticky fallback declaration. Check Can I use for the exact release if you must support a browser from before 2015.

Absolute, fixed and relative are part of CSS 2 and work everywhere. Our box model guide shows the padding box that absolute offsets measure from.

How we researched this

  • Specifications read on November 29, 2026: W3C CSS Positioned Layout Module Level 3 (Working Draft, 7 October 2025): the five value definitions, section 2.1 on containing blocks, section 3.4 on sticky positioning.
  • Documentation read the same day: MDN’s position reference and Containing block guide, Can I use’s position: sticky page. We compared the two MDN pages and found their lists of containing-block properties differ.
  • Searches: Google autocomplete for “css position”, “position sticky”, “position absolute”, position sticky not working, position absolute vs relative and position fixed vs sticky, fetched on November 29, 2026. Headings follow those phrases.
  • Our own tests: a 300 x 160px card with an 80 x 40px box, measured with getBoundingClientRect() in headless Chrome 158 (macOS), under all five values; sticky at eight scroll positions; a fixed child under eight ancestor properties; sticky in an overflow wrapper, a short parent, and a stretched flex row. One page, one browser, one run each.
  • What we did not do: we did not test in Firefox or Safari, did not test perspective, and did not count any user threads. The measured numbers are Chrome’s, and the rules quoted are the specs’ and MDN’s.

Open a page you made, put position: relative on one card, give a child position: absolute with top: 8px and right: 8px, then add a transform to the card’s parent and watch what a fixed child does. Ten minutes of that and the five values stop being a list to memorize.

Sources and further reading

Questions and answers

What is the difference between position absolute and relative?

A relative box stays in the flow, keeps its space, and moves from its own spot. An absolute box leaves the flow and measures from the nearest ancestor that is positioned. Put position: relative on the parent so the absolute child measures from it.

What is the difference between position fixed and sticky?

Fixed positions a box against the window and removes it from the flow. Sticky keeps the box in the flow and only holds it against an edge while its parent is on screen. Fixed suits a bar that must always stay; sticky suits a header that stays for its own section.

Why is position sticky not working?

Check four things: an offset like top: 0 is set, no ancestor has overflow other than visible, the parent is taller than the box, and the box is not a stretched flex or grid item (use align-self: flex-start).

Why is my position absolute element in the wrong place?

It measures from the nearest ancestor with a position other than static, or with a transform, filter or contain value. With none, it measures from the page’s corner. Add position: relative to the parent you meant.

What is the default CSS position?

The default is static. The box follows normal flow, and top, right, bottom, left and z-index have no effect until you set another value.

How this was written: Written from the W3C CSS Positioned Layout Module Level 3 (Working Draft, 7 October 2025), MDN Web Docs’ position reference and Containing block guide, Can I use’s position: sticky page, and Google autocomplete for "css position", "position sticky" and "position absolute", all read on November 29, 2026. Every coordinate in the diagram and tables is a measurement we took with getBoundingClientRect() in Chrome 158 on that date, or arithmetic from those numbers. Code samples are simplified for learning.

Oh, one more thing…

If this helped, you’ll like our free updates: the insights we discover while researching, and the moments worth sharing with other people learning CSS — no spam, no promotions.

One short email when there’s something worth your time. Unsubscribe any time.