Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Positioning | CSS Course lesson | BraveProgrammer
  1. Courses
  2. /
  3. CSS Course

Lesson 11 of 50

·css

Positioning

11 mins

Course progress22%

What you'll learn

Keep these ideas in mind as you work through the lesson.

3 points
  • `relative` is useful for small tweaks; it does **not** affect surrounding elements.
  • `absolute` needs a positioned ancestor (`position:relative|absolute|sticky`).
  • `sticky` allows a header or nav to stick after scrolling past its original spot.

Four positioning schemes:

ValueBehaviour
staticNormal flow (default).
relativeOffset from its static position; keeps space in flow.
absoluteRemoved from flow; positioned relative to the nearest positioned ancestor.
fixedRemoved from flow; positioned relative to the viewport (stays on scroll).
stickyBehaves like relative until a scroll threshold, then becomes fixed.

Example: Sticky header

header { position:sticky; top:0; background:#fff; z-index:10; }
Make it stickPractice what you've learned1 quiz · 6 practical tests · Optional activities from CSS CourseBrowse activities
Previous lessonDisplay PropertyContinue to lesson 12Floating & ClearingBack to CSS Course curriculum