Skip to main content
All interview theory questions
positionmedium

What do the CSS position values do?

Answer

static is the default and ignores offsets. relative keeps the element in flow but shifts it visually and creates a containing block for absolute children. absolute removes it from flow and positions it against the nearest positioned ancestor. fixed positions against the viewport and doesn't scroll. sticky behaves as relative until a scroll threshold, then pins — and it needs an offset like top: 0 to do anything.

Points an interviewer listens for

  • relative: stays in flow, becomes a positioning context
  • absolute: out of flow, relative to nearest positioned ancestor
  • fixed: relative to viewport
  • sticky: relative until threshold, then pinned — needs an offset

Reported at

Similar questions have been reported by candidates at Accenture, CallHippo, Infra.Market, Insignia Solutions, Kiaan Technology, Marmeto.

Now try answering it out loud

Interview practice mode times your spoken answer and checks it against the points above.

Practise this question