CSS Tutorial



CSS POSITION


CSS Position

The position property in CSS is used to specify the method of positioning an element in the document. It determines how an element is placed in the layout. The most commonly used values are:

  • static (default)
  • relative
  • absolute
  • fixed
  • sticky

1. Position: static (default)

Elements are positioned in the normal document flow. Top, left, bottom, and right have no effect.

This is a static element (default).

2. Position: relative

The element is positioned relative to its normal position. You can move it using top, left, right, or bottom.

This element is relative with top: 20px; left: 20px;

3. Position: absolute

The element is removed from the normal flow and positioned relative to the nearest positioned ancestor (not static).

I’m absolutely positioned inside a relative box.
This is a relatively positioned box containing the absolute element.

4. Position: fixed

Fixed elements stay in place relative to the browser window, even when scrolling.

I stay in the bottom-right corner!

(Scroll this page to see the fixed element stay in place.)

5. Position: sticky

Sticky elements toggle between relative and fixed, sticking when a defined offset is met during scroll.

I’m a sticky element. Scroll down to see how I stick at the top.

Scroll this section to see the sticky effect in action. Sticky positioning only works inside scrollable containers.

Summary Table

Position Type Behavior
static Normal flow, no top/left effects
relative Relative to its original position
absolute Relative to nearest positioned ancestor
fixed Stays in place relative to viewport
sticky Sticks when scrolled to a threshold
Tip: For absolute positioning to work as expected, make sure the parent has position: relative.

🌟 Enjoyed Learning with Us?

Help others discover Technorank Learning by sharing your honest experience.
Your support inspires us to keep building!

Leave a Google Review