Skip to main content

What is element positioning in CSS?

Positioning in CSS is the mechanism that defines how an element is placed on the page relative to other elements or the browser viewport. The position property controls positioning, setting the context and the rules for computing coordinates.

Main modes

position valueHow the element behaves
static (default)In the normal flow, no offset, coordinates do not work
relativeIn the flow, but can be shifted relative to its own position
absoluteRemoved from the flow, positioned relative to the nearest positioned ancestor
fixedRemoved from the flow, fixed relative to the browser window
stickyPartially in the flow, "sticks" on scroll once it reaches a given point

Coordinates (top, right, bottom, left) only work with relative, absolute, fixed, and sticky.

Essentially: positioning lets you control an element's exact location, either within the normal flow or outside it, anchored to the page, a parent element, or the viewport.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.