GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Tutorials
  • My W3Schools
  • W3Schools app iOS & Android NEW
  • Spaces
  • Get Certified
  • Plus
  • Practice
  • Campus (previously Academy)
  • Logout
  • 
  • 
  • 
  • 
  • Sign in

This view

  • Original page
  • New address

GeezerVison is showing www.w3schools.com — CSS Flexbox Items

Menu
Search field
×
See More  
NEW W3Schools app iOS & Android Start the adventure
Sign In
★ +1 Spaces Upgrade Paid Courses Spaces Upgrade Paid Courses
   ❮     
     ❯   
HTML CSS JAVASCRIPT SQL PYTHON JAVA PHP C C++ C# AWS W3.CSS HOW TO BOOTSTRAP REACT MYSQL JQUERY EXCEL XML DJANGO NUMPY PANDAS NODEJS DSA TYPESCRIPT ANGULAR ANGULARJS GIT POSTGRESQL MONGODB ASP AI R GO KOTLIN SWIFT SASS VUE GEN AI SCIPY CYBERSECURITY DATA SCIENCE INTRO TO PROGRAMMING INTRO TO HTML & CSS BASH RUST TOOLS

CSS Tutorial

CSS HOME CSS Introduction CSS Syntax CSS Selectors
Selectors Grouping Selectors Code Challenge
CSS How To
Add External CSS Add Internal CSS Add Inline Style Multiple Style Sheets Code Challenge
CSS Comments CSS Errors CSS Colors
Colors RGB / RGBA HEX / HEXA HSL / HSLA Code Challenge
CSS Backgrounds
Background Color Background Image Background Repeat Background Attachment Background Shorthand Code Challenge
CSS Borders
Border Style Border Width Border Color Border Sides Border Shorthand Rounded Borders Code Challenge
CSS Margins
Margins Margin Collapse Code Challenge
CSS Padding
Padding Padding box-sizing Code Challenge
CSS Height / Width
Height / Width Min / Max Code Challenge
CSS Box Model
Box Model Code Challenge
CSS Outline
Outline Style Outline Width Outline Color Outline Shorthand Outline Offset Code Challenge
CSS Text
Text Color Text Alignment Text Decoration Text Decoration Styles Text Transformation Text Spacing Text Shadow Code Challenge
CSS Fonts
Font Family Font Web Safe Font Fallbacks Font Style Font Size Font Google Font Pairings Font Shorthand Code Challenge
CSS Icons
Icons: Font Awesome Icons: Bootstrap Icons: Google Code Challenge
CSS Links
Styling Links Link Buttons Code Challenge
CSS Lists
Styling Lists Code Challenge
CSS Tables
Table Borders Table Size Table Alignment Table Styling Table Responsive Code Challenge
CSS Display
Display Visibility / Hide Code Challenge
CSS Max-width
Max-width Code Challenge
CSS Position
Static/Relative Position Fixed/Absolute Position Sticky Position Code Challenge
CSS Position Offsets
Offsets Code Challenge
CSS Z-index
Z-index Code Challenge
CSS Overflow
Overflow Overflow X and Y Code Challenge
CSS Float
Float Clear / Clearfix Float Examples Code Challenge
CSS Inline-block
Inline-block Code Challenge
CSS Align
Center Align Horizontal Align Vertical Align Code Challenge
CSS Combinators
Combinators Code Challenge
CSS Pseudo-classes
Pseudo-classes Interactive Structural Code Challenge
CSS Pseudo-elements
Pseudo-elements Text Content Code Challenge
CSS Opacity
Opacity Code Challenge
CSS Navigation Bars
Navbar Intro Vertical Navbar Horizontal Navbar Code Challenge
CSS Dropdowns
Dropdowns Advanced Dropdowns Code Challenge
CSS Image Gallery
Image Gallery Code Challenge
CSS Image Sprites
Image Sprites Code Challenge
CSS Attribute Selectors
Attribute Selectors Advanced Attr Selectors Code Challenge
CSS Forms
Style Forms Style Inputs Input Focus / Icons Other Form Elements Code Challenge
CSS Counters
Counters Nested Counters Code Challenge
CSS Units
Units Absolute Units Relative Units Code Challenge
CSS Inheritance
Inheritance Code Challenge
CSS Specificity
Specificity Specificity Hierarchy Code Challenge
CSS !important
!important Code Challenge
CSS Math Functions
Math Functions Code Challenge
CSS Optimization
Optimization Code Challenge
CSS Accessibility
Accessibility Code Challenge
CSS Website Layout
Website Layout Code Challenge

CSS Advanced

CSS Rounded Corners
Rounded Corners Code Challenge
CSS Border Images
Border Images Code Challenge
CSS Backgrounds
Multiple Backgrounds Background Size Background Origin Background Clip Code Challenge
CSS Colors
Colors Color Keywords Code Challenge
CSS Gradients
Linear Gradients Radial Gradients Conic Gradients Code Challenge
CSS Shadows
Text Shadow Box Shadow Code Challenge
CSS Text Effects
Text Effects Code Challenge
CSS Custom Fonts
Custom Fonts Code Challenge
CSS 2D Transforms
Translate / Rotate Scale Skew / Matrix Code Challenge
CSS 3D Transforms
3D Transforms 3D Perspective 3D Card Flip 3D Cube 3D Carousel Code Challenge
CSS Transitions
Transitions Transition Timing Code Challenge
CSS Animations
Animations Animation Timing Animation Properties Code Challenge
CSS Tooltips
Tooltips Tooltip Arrows Code Challenge
CSS Image Styling
Image Styling Image Effects Hover Overlays Code Challenge
CSS Image Modal
Image Modal Code Challenge
CSS Image Centering
Image Centering Code Challenge
CSS Image Filters
Image Filters Code Challenge
CSS Image Shapes
Image Shapes Code Challenge
CSS object-fit
object-fit Code Challenge
CSS object-position
object-position Code Challenge
CSS Masking
Masking - PNG Masking - Gradients Masking - SVG Code Challenge
CSS Buttons
Styling Buttons Hover Effects Button Groups Code Challenge
CSS Pagination
Pagination Pagination Styles Code Challenge
CSS Multiple Columns
Multiple Columns Multiple Column Rules Code Challenge
CSS User Interface
User Interface Code Challenge
CSS Variables
The var() Function Overriding Variables Variables and JavaScript Variables in MQ Code Challenge
CSS @property
@property Code Challenge
CSS Box Sizing
Box Sizing Code Challenge
CSS Functions CSS Media Queries
Media Queries MQ Examples Code Challenge

CSS Flexbox

Flexbox Intro
Flexbox Intro Code Challenge
Flex Container
Flexbox Container Flexbox Justify Content Flexbox Align Items Code Challenge
Flex Items
Flex Items Code Challenge
Flex Responsive
Flex Responsive Code Challenge

CSS Grid

Grid Intro
Grid Intro Code Challenge
Grid Container
Grid Container Grid Tracks Grid Gaps Grid Align Code Challenge
Grid Items
Grid Items Grid Item Named Grid Item Align Grid Item Order Code Challenge
Grid 12-column Layout
12-column Layout Code Challenge
CSS @supports
@supports Code Challenge

CSS Responsive

RWD Intro
RWD Intro Code Challenge
RWD Viewport
RWD Viewport Code Challenge
RWD Grid View
RWD Grid View Code Challenge
RWD Media Queries
RWD Media Queries Code Challenge
RWD Images
RWD Images Code Challenge
RWD Videos
RWD Videos Code Challenge
RWD Frameworks RWD Templates

CSS Cert

CSS Certificate

CSS SASS

SASS Tutorial

CSS Examples

CSS Templates CSS Examples CSS Videos CSS Editor CSS Snippets CSS Quiz CSS Exercises CSS Code Challenges CSS Website CSS Syllabus CSS Study Plan CSS Interview Prep

CSS References

CSS Reference CSS Selectors CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS At-rules CSS Functions CSS Reference Aural CSS Web Safe Fonts CSS Animatable CSS Units CSS PX-EM Converter CSS Colors CSS Color Values CSS Default Values CSS Browser Support

CSS Flex Items

❮ Previous Try Adventure Mode Next ❯

Share

CSS Flex Items

The direct child elements of a flex container automatically becomes flex items.

Flex items can have the following properties:

  • order - Specifies the display order of the flex items inside the flex container
  • flex-grow - Specifies how much a flex item will grow relative to the rest of the flex items
  • flex-shrink - Specifies how much a flex item will shrink relative to the rest of the flex items
  • flex-basis - Specifies the initial length of a flex item
  • flex - Shorthand property for flex-grow, flex-shrink, and flex-basis
  • align-self - Specifies the alignment for the flex item inside the flex container

CSS order Property

The order property specifies the display order of the flex items inside the flex container.

The first flex item in the source code does not have to appear as the first item in the layout.

The order value must be a number, and the default value is 0.

Example

The order value specifies the display order of the flex items:

<div class="flex-container">
  <div style="order: 3">1</div>
  <div style="order: 2">2</div>
  <div style="order: 4">3</div>
  <div style="order: 1">4</div>
</div>

Result:

1
2
3
4

Try it Yourself »


CSS flex-grow Property

The flex-grow property specifies how much a flex item will grow relative to the rest of the flex items.

The value must be a number, and the default value is 0.

Example

Make the third flex item grow four times faster than the other flex items:

<div class="flex-container">
  <div style="flex-grow: 1">1</div>
  <div style="flex-grow: 1">2</div>
  <div style="flex-grow: 4">3</div>
</div>

Result:

1
2
3

Try it Yourself »



CSS flex-shrink Property

The flex-shrink property specifies how much a flex item will shrink relative to the rest of the flex items.

The value must be a number, and the default value is 1.

Example

Let the third flex item shrink twice as much as the other flex items:

<div class="flex-container">
  <div>1</div>
  <div>2</div>
  <div style="flex-shrink: 2">3</div>
  <div>4</div>
  <div>5</div>
  <div>6</div>
</div>

Result:

1
2
3
4
5
6

Try it Yourself »


CSS flex-basis Property

The flex-basis property specifies the initial length of a flex item.

Example

Set the initial length of the third flex item to 250 pixels:

<div class="flex-container">
  <div>1</div>
  <div>2</div>
  <div style="flex-basis: 250px">3</div>
  <div>4</div>
</div>

Result:

1
2
3
4

Try it Yourself »


CSS flex Property

The flex property is a shorthand property for the flex-grow, flex-shrink, and flex-basis properties.

Example

Make the third flex item growable (1), not shrinkable (0), and with an initial length of 150 pixels:

<div class="flex-container">
  <div>1</div>
  <div>2</div>
  <div style="flex: 1 0 150px">3</div>
  <div>4</div>
</div>

Try it Yourself »


CSS align-self Property

The align-self property specifies the alignment for the selected item inside the flexible container.

This property overrides the default alignment set by the container's align-items property.

In these examples we use a 200 pixels high container, to better demonstrate the align-self property:

Example

Align the third flex item in the middle of the container:

<div class="flex-container">
  <div>1</div>
  <div>2</div>
  <div style="align-self: center">3</div>
  <div>4</div>
</div>

Result:

1
2
3
4

Try it Yourself »

Example

Align the second flex item at the top of the container, and the third flex item at the bottom of the container:

<div class="flex-container">
  <div>1</div>
  <div style="align-self: flex-start">2</div>
  <div style="align-self: flex-end">3</div>
  <div>4</div>
</div>

Result:

1
2
3
4

Try it Yourself »



The CSS Flex Items Properties

The following table lists all the CSS Flex Items properties:

Property Description
align-self Specifies the alignment for a flex item (overrides the flex container's align-items property)
flex A shorthand property for the flex-grow, flex-shrink, and the flex-basis properties
flex-basis Specifies the initial length of a flex item
flex-grow Specifies how much a flex item will grow relative to the rest of the flex items inside the container
flex-shrink Specifies how much a flex item will shrink relative to the rest of the flex items inside the container
order Specifies the order of the flex items inside the container

❮ Previous Next ❯
★ +1
Sign in to track progress
W3Schools Full Access - your next career move

REMOVE ADS

This way to the W3Schools Adventure app
Learn more about Adventure Mode›

Free account

Track your progress

XP earned 0 Day streak 0 Spaces 0 League —
Sign in to track progress

New

Learn in Adventure Mode W3Schools Adventure App

Coding fundamentals as bite-sized lessons and challenges.

PLUS
SPACES
GET CERTIFIED
FOR TEACHERS
PRACTICE
CONTACT US
×

Contact Sales

If you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail:
[email protected]

Report Error

If you want to report an error, or if you want to make a suggestion, send us an e-mail:
[email protected]

Top Tutorials
HTML Tutorial
CSS Tutorial
JavaScript Tutorial
How To Tutorial
SQL Tutorial
Python Tutorial
W3.CSS Tutorial
Bootstrap Tutorial
PHP Tutorial
Java Tutorial
C++ Tutorial
jQuery Tutorial
Top References
HTML Reference
CSS Reference
JavaScript Reference
SQL Reference
Python Reference
W3.CSS Reference
Bootstrap Reference
PHP Reference
HTML Colors
Java Reference
AngularJS Reference
jQuery Reference
Top Examples
HTML Examples
CSS Examples
JavaScript Examples
How To Examples
SQL Examples
Python Examples
W3.CSS Examples
Bootstrap Examples
PHP Examples
Java Examples
XML Examples
jQuery Examples
Get Certified
HTML Certificate
CSS Certificate
JavaScript Certificate
Front End Certificate
SQL Certificate
Python Certificate
PHP Certificate
jQuery Certificate
Java Certificate
C++ Certificate
C# Certificate
XML Certificate
   
FORUM ABOUT CAMPUS
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness
of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy.

Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS.









You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.