Junior JavaScript

What is the difference between relative, absolute, and fixed positioning?

Position Based On Moves with Page

Scroll?

Relative Its normal position ✅ Yes

Absolut

Nearest positioned

ancestor

✅ Yes

Fixed Viewport ❌ No

Example:

div { position: absolute; top: 10px; left: 20px; }

Key Takeaway:

Absolute is relative to parent; fixed stays on screen.

Follow me on LinkedIn:

More from JavaScript Tutorial

All questions for this course