Role of CSS flex-direction property column value

The CSS flex-direction: column property arranges flex items vertically in a column layout, stacking them from top to bottom. This is the opposite of the default row direction which arranges items horizontally.

Syntax

selector {
    display: flex;
    flex-direction: column;
}

Example

The following example demonstrates how to create a vertical layout using flex-direction: column

<!DOCTYPE html>
<html>
<head>
<style>
    .mycontainer {
        display: flex;
        flex-direction: column;
        background-color: orange;
        padding: 10px;
        width: 200px;
    }
    .mycontainer > div {
        background-color: white;
        text-align: center;
        line-height: 40px;
        font-size: 25px;
        width: 100px;
        margin: 5px;
        border-radius: 5px;
    }
</style>
</head>
<body>
    <h1>Quiz</h1>
    <div class="mycontainer">
        <div>Q1</div>
        <div>Q2</div>
        <div>Q3</div>
        <div>Q4</div>
        <div>Q5</div>
        <div>Q6</div>
    </div>
</body>
</html>
A heading "Quiz" appears followed by an orange container with six white boxes labeled Q1 through Q6 stacked vertically in a column layout.

Conclusion

The flex-direction: column property is essential for creating vertical layouts in flexbox. It changes the main axis from horizontal to vertical, making flex items stack from top to bottom.

Updated on: 2026-03-15T13:06:53+05:30

186 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements