Module 7 · Lesson 1 of 425/60 in the course~20 min
Module lessons (1/4)
Main Axis, Cross Axis, justify-content & align-items
Lesson preview5 hands-on exercises readyModern HTML & CSS · Flexbox Layout in Depth
Orient single-axis row and column layouts cleanly with gap, justify-content, and align-items.
What you'll learn in this lesson
- Align items cleanly along one primary direction using
display: flexandgap. - Distinguish the Main Axis (
justify-content) from the Cross Axis (align-items) and watch both rotate underflex-direction: column. - Center elements effortlessly both horizontally and vertically without negative margins.
Overview
Unlike CSS Grid (designed for 2D rows AND columns together), Flexbox excels at distributing space along one axis at a time: a row of navbar links, a group of pill tags, or a vertical card stack.
Every alignment property answers one question: _"Are we aligning along the flow direction (justify-content), or perpendicular to it (align-items)?"_
Sections covered in this lesson
- 1Think in Two Rotating Axes
- 2Rotate Main & Cross Axes Live
Pro Lesson · Flexbox Layout in Depth
Unlock "Main Axis, Cross Axis, justify-content & align-items" and the full Modern HTML & CSS curriculum
Orient single-axis row and column layouts cleanly with gap, justify-content, and align-items.
Unlock all 5 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.
- Instant access to all advanced modules in Modern HTML & CSS plus 17 more courses
- Hands-on browser exercises with automated test suites and solutions
- 14-day money-back guarantee processed via Paddle.com
14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.