CSS flex-flow Property

The flex-flow property is a shorthand that defines the direction of flex items and whether they can wrap onto additional lines.

It combines the flex-direction and flex-wrap properties into a single declaration. This makes it useful for creating horizontal, vertical, reversed, and wrapping layouts within a flex container.

flex-flow Syntax

The flex-flow property accepts one or two values representing flex direction and wrapping behavior.

Basic Syntax

selector {
  flex-flow: row wrap;
}

Direction and Wrapping

.container {
  flex-flow: row nowrap;
}
.container {
  flex-flow: row wrap;
}
.container {
  flex-flow: row wrap-reverse;
}
.container {
  flex-flow: column nowrap;
}
.container {
  flex-flow: column wrap;
}
.container {
  flex-flow: column-reverse wrap;
}

Single-Value Syntax

.container {
  flex-flow: column;
}
.container {
  flex-flow: wrap;
}
.container {
  flex-flow: wrap-reverse;
}

CSS-Wide Keywords

.container {
  flex-flow: inherit;
}
.container {
  flex-flow: initial;
}
.container {
  flex-flow: unset;
}
.container {
  flex-flow: revert;
}
.container {
  flex-flow: revert-layer;
}

The initial value is row nowrap. Both component values are optional, but at least one must be supplied. An omitted component is reset to its initial value.

The two values can appear in either order, although writing the direction before the wrapping value is a common convention.

Property Values

The flex-flow shorthand accepts the directional values of flex-direction and the wrapping values of flex-wrap.

Direction Values

Value Description
row Arranges flex items along the inline axis.
row-reverse Reverses the main direction along the inline axis.
column Arranges flex items along the block axis.
column-reverse Reverses the main direction along the block axis.

Wrapping Values

Value Description
nowrap Places all flex items on one flex line, even when they overflow the container.
wrap Allows items to continue onto additional flex lines when needed.
wrap-reverse Allows wrapping while reversing the cross-start and cross-end directions.

CSS-Wide Values

Value Description
inherit Inherits both component values from the parent.
initial Resets the shorthand to row nowrap.
unset Resets both components to their initial values because neither is inherited.
revert Reverts both components according to the CSS cascade origins.
revert-layer Reverts both components according to the CSS cascade layers.

Property Characteristics

Characteristic Value
Initial value row nowrap
Inherited No
Applies to Flex containers
Computed value See individual component properties
Animation type See individual component properties
Percentages Not applicable

Both component properties use discrete animation. Changes between directions or wrapping modes do not interpolate smoothly.

Shorthand Properties

The flex-flow shorthand combines two properties that control the arrangement of items within a flex container.

Property Initial Value Purpose
flex-direction row Defines the main axis and direction of the flex items.
flex-wrap nowrap Determines whether items remain on one line or wrap onto additional lines.

Individual Properties

.container {
  flex-direction: row;
  flex-wrap: wrap;
}

Equivalent Shorthand

.container {
  flex-flow: row wrap;
}

Common Shorthand Expansions

Shorthand flex-direction flex-wrap
flex-flow: row row nowrap
flex-flow: column column nowrap
flex-flow: wrap row wrap
flex-flow: row wrap row wrap
flex-flow: column wrap column wrap
flex-flow: row-reverse wrap-reverse row-reverse wrap-reverse

Resetting Omitted Values

.container {
  flex-direction: column;
  flex-flow: wrap;
}

The resulting direction is row, not column, because flex-flow: wrap resets the omitted flex-direction component to its initial value.

This reset behavior is important when mixing shorthand and longhand declarations.

How It Works

The flex-flow property controls two related aspects of the flex formatting context: the main axis and the arrangement of flex lines.

Step 1: Establish a Flex Container

.container {
  display: flex;
}

By default, the container uses flex-flow: row nowrap.

Step 2: Enable Wrapping

.container {
  display: flex;
  flex-flow: row wrap;
}

Items follow the inline axis and can move onto additional flex lines when they no longer fit.

Step 3: Change the Main Axis

.container {
  display: flex;
  flex-flow: column wrap;
  height: 300px;
}

Items follow the block axis and can continue into additional columns when the available main-axis space is insufficient.

Step 4: Reverse the Direction

.container {
  display: flex;
  flex-flow: row-reverse wrap;
}

The main direction is reversed while wrapping remains enabled.

Important Distinction

The direction value controls the main axis. The wrapping value controls whether multiple flex lines are created and, for wrap-reverse, the direction of the cross axis.

row nowrap

The value row nowrap is the initial flex-flow configuration. It places flex items along the inline axis on a single flex line.

Syntax

.container {
  display: flex;
  flex-flow: row nowrap;
}

Example

.navigation {
  display: flex;
  flex-flow: row nowrap;
  gap: 12px;
}

How It Works

All items remain on one flex line. If the combined item sizes exceed the available main-axis space, items may shrink according to their flex settings or overflow when shrinking is insufficient.

Important Consideration

nowrap does not guarantee that every item will fit. Minimum sizes, nonshrinking items, and long content can cause overflow.

row wrap

The value row wrap arranges items along the inline axis and allows them to continue onto additional flex lines.

Syntax

.container {
  display: flex;
  flex-flow: row wrap;
}

Example

.cards {
  display: flex;
  flex-flow: row wrap;
  gap: 15px;
}
.card {
  flex: 1 1 200px;
}

How It Works

Each card starts with a flex basis of 200px. When the container cannot accommodate all the cards on one line, additional flex lines are created.

Important Consideration

Each flex line is sized independently. Items on different lines do not automatically form aligned columns of equal width.

row wrap-reverse

The value row wrap-reverse allows horizontal wrapping while reversing the direction in which flex lines are stacked along the cross axis.

Syntax

.container {
  display: flex;
  flex-flow: row wrap-reverse;
}

Example

.reverse-wrap {
  display: flex;
  flex-flow: row wrap-reverse;
  gap: 10px;
  min-height: 180px;
}
.reverse-wrap > div {
  flex: 0 0 100px;
}

How It Works

In a typical left-to-right horizontal writing mode, items still progress from left to right within each line, but the flex lines are stacked in the opposite vertical direction.

Important Consideration

wrap-reverse reverses the cross axis, not the order of items within each flex line. Use row-reverse to reverse the main direction.

column nowrap

The value column nowrap arranges items along the block axis while keeping them on one flex line.

Syntax

.container {
  display: flex;
  flex-flow: column nowrap;
}

Example

.vertical-navigation {
  display: flex;
  flex-flow: column nowrap;
  gap: 10px;
}

How It Works

In a horizontal writing mode, the items stack vertically. They remain in a single column even if their combined heights exceed the available space.

Important Consideration

A definite container height is not required for a basic vertical stack. However, a constrained height may be needed when distributing vertical free space using flex growth or alignment.

column wrap

The value column wrap arranges items along the block axis and allows additional flex lines to form when the available main-axis space is insufficient.

Syntax

.container {
  display: flex;
  flex-flow: column wrap;
}

Example

.column-layout {
  display: flex;
  flex-flow: column wrap;
  height: 250px;
  gap: 10px;
}
.column-layout > div {
  flex: 0 0 70px;
  width: 100px;
}

How It Works

Items are placed vertically until the available main-axis height is insufficient. Additional items continue into new flex lines along the cross axis, creating more columns in a typical horizontal writing mode.

Important Consideration

Column wrapping generally requires a constrained main-axis size, such as a definite height. Without that constraint, the container may expand vertically rather than create additional columns.

Reversed Directions

The row-reverse and column-reverse values can be combined with any wrapping mode.

Reversed Row

.container {
  display: flex;
  flex-flow: row-reverse wrap;
}

Items follow the inline axis in reverse, while wrapping remains enabled.

Reversed Column

.container {
  display: flex;
  flex-flow: column-reverse nowrap;
}

Items follow the block axis in reverse and remain on a single flex line.

Reversing Both Axes

.container {
  display: flex;
  flex-flow: row-reverse wrap-reverse;
}

The main direction is reversed by row-reverse, while wrap-reverse reverses the cross-axis direction used for wrapping.

Source Order

Reversing either axis does not change the HTML source order. The visual positions may differ from the reading and keyboard navigation order.

Important Consideration

The physical direction of reversed layouts also depends on writing-mode and direction. A reversed row does not always mean right to left.

Single-Value Syntax

Only one component is required in a flex-flow declaration. The omitted component receives its initial value.

Direction Only

.container {
  flex-flow: column;
}

This is equivalent to flex-flow: column nowrap.

Wrapping Only

.container {
  flex-flow: wrap;
}

This is equivalent to flex-flow: row wrap.

Reverse Wrapping Only

.container {
  flex-flow: wrap-reverse;
}

This is equivalent to flex-flow: row wrap-reverse.

Value Order

.container-one {
  flex-flow: row wrap;
}
.container-two {
  flex-flow: wrap row;
}

Both declarations produce the same component values.

Important Consideration

Use both values when the direction and wrapping behavior should be explicit. This also helps avoid accidental resets when a shorthand overrides earlier longhand declarations.

flex-flow vs. flex

The flex-flow and flex properties are both shorthands, but they control different aspects of Flexbox.

flex-flow

.container {
  display: flex;
  flex-flow: row wrap;
}

This shorthand is applied to the flex container and controls direction and wrapping.

flex

.item {
  flex: 1 1 200px;
}

This shorthand is applied to individual flex items and controls growth, shrinking, and the initial main size.

Comparison

Characteristic flex-flow flex
Applied to Flex container Flex item
Controls Direction and wrapping Growth, shrinking, and basis
Components flex-direction, flex-wrap flex-grow, flex-shrink, flex-basis
Example row wrap 1 1 200px

Using Both Together

.container {
  display: flex;
  flex-flow: row wrap;
  gap: 15px;
}
.container > div {
  flex: 1 1 200px;
}

The container controls the arrangement of flex lines, while each item controls how its size responds to the available space.

Sizing and Wrapping

The wrapping behavior of flex-flow depends on the flex items' hypothetical main sizes and the available space in the container.

Flexible Cards

.container {
  display: flex;
  flex-flow: row wrap;
  gap: 15px;
}
.card {
  flex: 1 1 220px;
}

Cards start with a basis of 220px. When the container cannot accommodate another card on the current line, a new flex line is created.

Nonshrinking Items

.container {
  display: flex;
  flex-flow: row wrap;
}
.item {
  flex: 0 0 200px;
}

Each item uses a nonflexible basis of 200px. Items wrap when they cannot fit together on the current line.

Gap Spacing

.container {
  display: flex;
  flex-flow: row wrap;
  gap: 20px;
}

The gap contributes to the space required between items and flex lines, so it can influence how many items fit on each line.

Independent Flex Lines

Each flex line performs its own flexible sizing. Items on separate lines do not automatically share a common column width.

Important Consideration

For layouts that require strict alignment across multiple rows and columns, CSS Grid may be more suitable than a wrapping flex container.

Responsive Layouts

The flex-flow shorthand is useful for layouts that change direction or wrapping behavior at different viewport widths.

Responsive Card Layout

.card-container {
  display: flex;
  flex-flow: row wrap;
  gap: 15px;
}
.card {
  flex: 1 1 240px;
  min-width: 0;
}

Cards share the available horizontal space and wrap onto additional lines as needed.

Responsive Navigation

.navigation {
  display: flex;
  flex-flow: row wrap;
  gap: 12px;
}
@media (max-width: 600px) {
  .navigation {
    flex-flow: column nowrap;
  }
}

On smaller screens, navigation items change from a wrapping horizontal arrangement to a single vertical column.

Responsive Sidebar

.layout {
  display: flex;
  flex-flow: row nowrap;
  gap: 20px;
}
.sidebar {
  flex: 0 0 220px;
}
.main-content {
  flex: 1;
  min-width: 0;
}
@media (max-width: 700px) {
  .layout {
    flex-flow: column nowrap;
  }
  .sidebar {
    flex: 0 1 auto;
  }
  .main-content {
    flex: 1 1 auto;
  }
}

The layout uses a horizontal arrangement on wider screens and stacks the sidebar and content vertically on narrower screens.

Important Consideration

When switching between row and column directions, review flex bases, minimum sizes, and alignment properties. The main axis changes, so existing sizing values may affect a different physical dimension.

flex-flow Example

This example compares a single row, a wrapping row, reversed wrapping, and a vertical column layout. The same numbered items are used in each arrangement.

HTML Example

<div class="flow-demo">
  <h3>row nowrap</h3>
  <div class="flow-row-nowrap">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
  </div>
  <h3>row wrap</h3>
  <div class="flow-row-wrap">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
  </div>
  <h3>row wrap-reverse</h3>
  <div class="flow-row-wrap-reverse">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
  </div>
  <h3>column nowrap</h3>
  <div class="flow-column-nowrap">
    <div>1</div>
    <div>2</div>
    <div>3</div>
    <div>4</div>
  </div>
</div>

CSS Example

.flow-demo > div {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 260px;
  padding: 10px;
  margin-bottom: 20px;
  background-color: #f1f5f9;
}
.flow-demo > div > div {
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 70px;
  min-height: 40px;
  background-color: #336699;
  color: #fff;
  font-weight: bold;
}
.flow-demo .flow-row-nowrap {
  flex-flow: row nowrap;
}
.flow-demo .flow-row-wrap {
  flex-flow: row wrap;
}
.flow-demo .flow-row-wrap-reverse {
  flex-flow: row wrap-reverse;
}
.flow-demo .flow-column-nowrap {
  flex-flow: column nowrap;
}
.flow-demo .flow-column-nowrap > div {
  flex: 0 0 40px;
}
Browser Result

row nowrap

1
2
3
4

row wrap

1
2
3
4

row wrap-reverse

1
2
3
4

column nowrap

1
2
3
4

The row nowrap example keeps all four items on one line, causing horizontal overflow because the items cannot shrink. The row wrap example creates additional lines, while row wrap-reverse reverses the cross-axis stacking direction. The column nowrap example stacks the items vertically.

The items retain their original HTML source order in all four examples.

Accessibility

The flex-flow property changes visual arrangement without changing the semantic meaning or document order of flex items.

Preserve Logical Source Order

Arrange HTML elements in a meaningful reading sequence. Reversed flex directions should not be used to correct an unsuitable source order.

Keyboard Navigation

Keyboard focus generally follows the document order rather than the reversed visual arrangement. Test interactive layouts that use row-reverse or column-reverse.

Avoid Unnecessary Overflow

When nowrap causes content to extend beyond the container, consider wrapping, responsive adjustments, or suitable scrolling behavior.

Support Text Resizing

Test layouts with enlarged text and longer labels. Wrapping can help prevent content from becoming inaccessible at narrower widths.

Responsive Reading Order

When switching from horizontal to vertical layouts, ensure the visual sequence remains consistent with the intended reading and interaction order.

Important Consideration

Flexbox visual reordering does not change the accessibility tree. Maintain logical HTML structure and avoid using reversed directions for meaningful content sequences.

Important Considerations

Keep the following points in mind when using flex-flow:

  • Purpose: Combines flex direction and wrapping behavior.
  • Initial value: row nowrap.
  • Inheritance: The property is not inherited.
  • Applies to: Flex containers.
  • Components: flex-direction and flex-wrap.
  • row: Arranges items along the inline axis.
  • row-reverse: Reverses the inline-axis main direction.
  • column: Arranges items along the block axis.
  • column-reverse: Reverses the block-axis main direction.
  • nowrap: Keeps items on one flex line.
  • wrap: Allows additional flex lines when needed.
  • wrap-reverse: Reverses the cross-axis direction used for wrapping.
  • Single values: An omitted component receives its initial value.
  • Value order: Direction and wrapping values can appear in either order.
  • Shorthand reset: A flex-flow declaration resets both component properties.
  • Main axis: Determined by the direction component.
  • Cross axis: Perpendicular to the main axis.
  • Writing modes: Physical directions depend on writing-mode and direction.
  • Column wrapping: Generally requires a constrained main-axis size.
  • Flex lines: Each line is sized independently.
  • Item sizing: Controlled separately by flex and its longhand properties.
  • Gap: Affects the space available for items and flex lines.
  • Responsive layouts: Media queries can change direction and wrapping together.
  • Visual order: Reversed directions do not change HTML source order.
  • Animation: Changes between component values are discrete.
  • Accessibility: Keep visual and keyboard navigation sequences understandable.

Use flex-flow when both direction and wrapping behavior need to be defined together. It provides a compact way to configure flex containers for navigation, responsive cards, stacked sections, and other flexible layouts.

Browser Support

The CSS flex-flow property is Widely available and supported by modern browsers, including Chrome, Edge, Firefox, and Safari.

The standard, unprefixed shorthand and its direction and wrapping values have broad support. Older browsers may have used prefixed or earlier Flexbox implementations.

Supported Example

.container {
  display: flex;
  flex-flow: row wrap;
}

Feature Detection

@supports (display: flex) and (flex-flow: row wrap) {
  .container {
    display: flex;
    flex-flow: row wrap;
  }
}

Fallback Example

.container > div {
  display: block;
}
@supports (display: flex) and (flex-flow: row wrap) {
  .container {
    display: flex;
    flex-flow: row wrap;
  }
}

The fallback leaves items in normal block layout when Flexbox is unsupported. Supporting browsers use a wrapping flex row.

Compatibility Considerations

Although Flexbox support is broad, test layouts involving reversed directions, multiple flex lines, and constrained column heights in the browsers your site supports.

For current compatibility information, visit Can I Use? .

Specifications

The flex-flow shorthand is defined in the CSS Flexible Box Layout Module Level 1. The specification describes how direction and wrapping are combined to determine the main axis and flex line arrangement.

CSS Flexible Box Layout Module Level 1: flex-flow Property

The same specification defines the individual direction and wrapping properties.

CSS Flexible Box Layout Module Level 1: flex-direction Property

CSS Flexible Box Layout Module Level 1: flex-wrap Property

These definitions establish the behavior of single-line and multiline flex containers, reversed directions, and the relationship between main-axis and cross-axis layout.