CSS flex-wrap Property
Description
The flex-wrap property controls whether flex items are forced onto a single line or allowed to form multiple lines inside a flex container. When wrapping is permitted, the items create additional flex lines along the container’s cross axis; each line is treated as a separate row (or column, depending on axis orientation) and items on later lines participate in layout and alignment independently of items on earlier lines. Allowing wrapping is a common way to prevent overflow of child elements and to enable more fluid, content-driven layouts where items naturally reflow when container size changes.
Because wrapping affects how items are distributed across the container’s axes, it must be considered together with how the container is established and oriented — for example, with display set to create a flex formatting context and the chosen flex-direction, which defines the main and cross axes. There is also a shorthand that combines orientation and wrapping behavior, flex-flow, making it convenient to set both aspects in a single declaration. Changes to the axis orientation or enabling wrapping can dramatically alter visual order, line breaks, and the direction in which new lines are added.
When multiple lines exist, the spacing and distribution of those lines along the cross axis is controlled separately from individual item alignment — for that purpose align-content becomes important, since it governs how the lines themselves are packed or stretched inside the container. Wrapping also interacts with item sizing behaviors (flex-basis, min/max constraints, and growth/shrink behavior) so that the same set of items can produce very different layouts depending on whether wrapping is allowed. Practically, enabling wrapping is a key tool for responsive design: it lets items reorganize into multiple rows or columns as available space changes, avoiding horizontal overflow and enabling predictable stacking without resorting to absolute positioning or media-query-only approaches.
Definition
- Initial value
- nowrap
- Applies to
- Flex containers
- Inherited
- No
- Computed value
- As specified
- Animatable
- No
- JavaScript syntax
- object.style.flexWrap
Interactive Demo
Syntax
flex-wrap: nowrap | wrap | wrap-reverse
Values
- nowrapIndicates that flex items line up on a single line. This is the default value.
- wrapIndicates that flex elements inside the container are located in several horizontal rows (in case of overflow). Flex elements are placed from left to right with the ltr direction (global HTML dir attribute, or CSS direction property with ltr value), and with rtl value they are placed from right to left.
- wrap-reverseIndicates that the flex elements inside the container are arranged in several horizontal rows (in case of overflow) similar to the wrap value, but the lines are formed in the reverse order.
Example
Browser Support
The following information will show you the current browser support for the CSS flex-wrap property. Hover over a browser icon to see the version that first introduced support for this CSS property.
This property is supported by all modern browsers.
Desktop
Tablets & Mobile
Last updated by CSSPortal on: 1st January 2026
