HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
  • Insights
  • Verify Certificate
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials
HTML5ANDCSS3 logoHTML5ANDCSS3Tools and Tutorials

HTML5andCSS3.org helps developers learn modern frontend skills with practical tutorials, production-ready snippets, and fast web tools built for everyday coding.

Quick Links

  • About Us
  • Contact Us
  • Privacy Policy
  • Copyright
  • Disclaimer

Top Tools

  • Try It Editor
  • JSON Formatter
  • CSS Minifier
  • HTML Minifier
  • Base64 Encoder / Decoder

Contact

  • business@html5andcss3.org
Newsletter

Learn at your own pace, practice with useful tools, and build websites you're proud of.

© 2011-2026 html5andcss3.org. All rights reserved.

How to Use

CSS Tutorial

CSS Introduction

What is CSSCSS SyntaxHow to Add CSSCSS Comments

CSS Foundations

Cascade & InheritanceCSS SpecificityCSS UnitsBox SizingCSS VariablesCSS Math Functions

CSS Selectors

CSS Element SelectorCSS Class SelectorCSS ID SelectorCSS Universal SelectorCSS Group SelectorCSS CombinatorsCSS Attribute SelectorsCSS Pseudo ClassesCSS Pseudo Elements

CSS Colors and Backgrounds

CSS ColorsCSS HEX ColorsCSS RGB ColorsModern ColorsCSS Background ColorCSS Background ImageLayered Backgrounds

CSS Text & Fonts

CSS Text ColorCSS Text AlignmentCSS Text DecorationCSS Font FamilyCSS Font SizeWeb Fonts & TypographyText Wrapping

CSS Box Model

CSS MarginCSS PaddingCSS BorderCSS OutlineCSS Width and Height

CSS Layout

Normal FlowCSS DisplayCSS PositionAnchor PositioningCSS FloatCSS OverflowCSS Z-indexIntrinsic SizingAspect Ratio & Object FitMulti-column Layout

CSS Flexbox

Flex ContainerFlex DirectionJustify ContentAlign ItemsFlex WrapFlex Item Sizing

CSS Grid

CSS Grid ContainerCSS Grid ColumnsCSS Grid RowsCSS Grid GapCSS Grid Layout ExampleGrid PlacementGrid AreasCSS Subgrid

CSS Lists, Tables & Forms

CSS ListsCSS TablesCSS Form StylingCSS Input Fields

CSS Effects

CSS ShadowsCSS GradientsCSS FiltersCSS OpacityClipping & MaskingBlending & BackdropScroll Snap

CSS Animations & Transitions

CSS TransformCSS 2D TransformCSS 3D TransformCSS TransitionsEntry & Exit TransitionsCSS AnimationsScroll AnimationsView TransitionsMotion Paths

CSS Responsive Design

CSS Media QueriesResponsive LayoutMobile First DesignContainer QueriesPreference Media QueriesFeature Queries

Modern CSS Authoring

Cascade LayersNesting & ScopeLogical PropertiesGenerated Content

CSS Accessibility

Accessible CSSCSS ThemingModern Form StylingCSS User Interface

CSS Output & Performance

Print StylesCSS PerformanceCSS ArchitectureDebugging CSS

CSS Reference

CSS At-rulesCSS FunctionsCSS Tutorial PDF

CSS Projects

Responsive CSS Project
  1. Home
  2. /
  3. Tutorials
  4. /
  5. CSS Tutorial
  6. /
  7. Flex Wrap

CSS Flexbox

Flex Wrap

The flex-wrap property controls whether flex items should stay on a single line or wrap onto multiple lines when there is not enough space in the flex container.

By default, Flexbox tries to keep all items on one line. When many items are present or the container becomes smaller, items may overflow. The supporting concepts are explained in Flex Container and Flex Item Sizing.

The flex-wrap property helps create responsive layouts by allowing items to move to the next line automatically.

Syntax

Flex Wrap Syntax

css

.container {
    display: flex;
    flex-wrap: value;
}

Flex Wrap Example

css

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

This allows flex items to move onto the next line when necessary.

Attributes

ValueDescriptionExample
nowrapDefault. All items stay on one lineflex-wrap: nowrap;
wrapItems wrap onto the next lineflex-wrap: wrap;
wrap-reverseItems wrap in reverse orderflex-wrap: wrap-reverse;

Example

Flex Wrap Complete Example

html

<!DOCTYPE html>
<html>
<head>
    <title>Flex Wrap Example</title>
    <style>
        .container {
            display: flex;
            flex-wrap: wrap;
            width: 500px;
            border: 2px solid black;
            gap: 10px;
            padding: 10px;
        }
        .item {
            width: 120px;
            padding: 20px;
            text-align: center;
            background-color: lightblue;
            border: 1px solid #333;
        }
    </style>
</head>
<body>
    <div class="container">
        <div class="item">Item 1</div>
        <div class="item">Item 2</div>
        <div class="item">Item 3</div>
        <div class="item">Item 4</div>
        <div class="item">Item 5</div>
        <div class="item">Item 6</div>
    </div>
</body>
</html>

Browser Support

Feature
Chrome
Edge
Firefox
Safari
flex-wrap2912289

Versions show the first stable desktop release with unprefixed support. Data source: MDN Browser Compatibility Data 8.0.8.

Notes

  • nowrap is the default Flexbox behavior.
  • wrap is commonly used in responsive layouts.
  • wrap-reverse places wrapped rows in reverse order.
  • Often combined with justify-content, align-items, and gap.
  • Helps prevent content overflow on smaller screens.

Visual Comparison

nowrap

text

Item1 Item2 Item3 Item4 Item5 Item6

wrap

text

Item1 Item2 Item3
Item4 Item5 Item6

wrap-reverse

text

Item4 Item5 Item6
Item1 Item2 Item3

Conclusion

The flex-wrap property determines how flex items behave when space is limited. By allowing items to wrap onto multiple lines, it helps create flexible, responsive, and user-friendly layouts that adapt to different screen sizes.

PreviousAlign ItemsNextFlex Item Sizing