flex-direction property
Specifies the direction of the main axis which specifies how the flex items are displayed in the flex container.
This property is read/write.
![]() ![]() |
Syntax
flex-direction: row | row-reverse | column | column-reverse
Property values
One of the following display order values.
row-
Sets the flex container's main axis to the same orientation as the inline axis of the current writing mode.
row-reverse-
Same as row, but with the start and end points of the axis reversed.
column-
Sets the flex container's main axis to be the same orientation as the block axis (the vertical axis in horizontal writing modes and the horizontal axis in vertical writing modes) of the current writing mode. Flex items are displayed in the same order that they are declared in the source document, from top to bottom.
column-reverse-
Same as column, but with the start and end points of the axis reversed.
CSS information
| Applies To | flex containers |
|---|---|
| Media | visual |
| Inherited | no |
| Initial Value | row |
Standards information
Remarks
As of Microsoft Edge, the "-ms-" prefixed version of this property is not supported.
As of Internet Explorer for Windows Phone 8.1 Update and Microsoft Edge, IE supports "-webkit-box-direction", "-webkit-box-orient", or "-webkit-flex-direction" as an alias for this property.
The main axis determines the direction of items placed inside a flex container.
The reverse values do not reverse box ordering like writing-mode and direction, they only change the direction of flow. Painting, speech, and sequential navigation orders are not affected.
As of Internet Explorer for Windows Phone 8.1 Update and Microsoft Edge, IE supports the deprecated "-webkit-box-orient" property for interoperability purposes. In the current standard, "-webkit-box-direction and "-webkit-box-orient" are combined as flex-direction.
Examples
The CSS examples and images show the different values for flex-direction using the HTML snippet below. This flex container contains three flex items, has a height of 170 pixels, and a grey border.
<div id="flexContainer"> <div id="item1">1</div> <div id="item2">2</div> <div id="item3">3</div> </div>
In the CSS below, flex-direction is set to row. The flex container's main axis is set to the same orientation as the inline axis of the current writing mode, which for this example is the default, left-to-right.

#flexContainer {
height: 170px;
border: solid 1px #949494;
display: flex;
flex-direction: row;
}
In the CSS below, flex-direction is set to row-reverse. This example is similar to the row example above, but with the start and end points of the axis reversed.

#flexContainer {
height: 170px;
border: solid 1px #949494;
display: flex;
flex-direction: row-reverse;
}
In the CSS below, flex-direction is set to column. In this example, the flex container's main axis is set to be the same orientation as the block axis (the vertical axis in horizontal writing modes and the horizontal axis in vertical writing modes) of the current writing mode. Flex items are displayed in the same order that they are declared in the source document, from top to bottom.

#flexContainer {
height: 170px;
border: solid 1px #949494;
display: flex;
flex-direction: column;
}
In the CSS below, flex-direction is set to column-reverse. This example is similar to the column example above, but the start and end points of the axis reversed.

#flexContainer {
height: 170px;
border: solid 1px #949494;
display: flex;
flex-direction: column-reverse;
}
See also

