Skip to content

CSS Tutorial CSS Position

CSS Position

Lesson 73 of 182 2 min read By Deepak Paswan Updated Oct 4, 2026

Normally, the browser places elements one after another in a natural flow, top to bottom. The position property lets you step outside that flow when you need to.

Five values

ValueWhat it does
staticThe default. Normal flow. top, left etc. are ignored
relativeNormal flow, but you can nudge the element from its original spot
absoluteTaken out of the flow and placed relative to its nearest positioned ancestor
fixedPlaced relative to the browser window and stays there when you scroll
stickyBehaves normally until you scroll past it, then sticks

The offset properties

Position by itself does nothing visible. The movement comes from top, right, bottom and left.

index.html
HTML
<style>
  .box { background: #d0e8f2; border: 1px solid #1a5276; padding: 10px; margin: 6px 40px 6px 0; }
  .moved { position: relative; top: 14px; left: 30px; background: #fdebd9; }
</style>
<div class="box">Normal box</div>
<div class="box moved">Relative box, nudged 14px down and 30px right</div>
<div class="box">Normal box. It did not move to fill the gap.</div>

Notice that the box below did not move up. A relatively positioned element keeps its original space.

static is the default

Every element is static until you change it. Setting top: 20px on a static element changes nothing. If an offset seems to do nothing, check position first.

The next lessons

Each value has its own lesson: relative, absolute, fixed and sticky. Overlap is controlled by z-index.

lightbulb
Layouts are usually flexbox or grid
position is excellent for badges, overlays, tooltips, sticky headers and little adjustments. For arranging whole sections of a page, Flexbox and Grid are the right tools.