Usage of CSS align-content property flex-start value

The CSS align-content property with the flex-start value aligns flex lines to the beginning (top) of the flex container. This property only works when there are multiple lines of flex items, which requires flex-wrap: wrap to be set.

Syntax

selector {
    align-content: flex-start;
}

Example

The following example demonstrates how align-content: flex-start positions flex lines at the top of the container −

<!DOCTYPE html>
<html>
<head>
<style>
    .mycontainer {
        display: flex;
        height: 200px;
        width: 400px;
        background-color: lightblue;
        align-content: flex-start;
        flex-wrap: wrap;
        border: 2px solid #333;
    }
    .mycontainer > div {
        background-color: orange;
        text-align: center;
        line-height: 60px;
        font-size: 20px;
        width: 80px;
        height: 60px;
        margin: 5px;
        border-radius: 5px;
    }
</style>
</head>
<body>
    <h2>Flex Container with align-content: flex-start</h2>
    <div class="mycontainer">
        <div>Item 1</div>
        <div>Item 2</div>
        <div>Item 3</div>
        <div>Item 4</div>
        <div>Item 5</div>
        <div>Item 6</div>
    </div>
</body>
</html>
A light blue flex container with orange rounded items arranged in multiple rows, all positioned at the top of the container with remaining space below.

Key Points

  • align-content: flex-start only affects multi-line flex containers
  • Requires flex-wrap: wrap or flex-wrap: wrap-reverse
  • Positions all flex lines at the start of the cross axis (top by default)
  • Any extra space appears after the flex lines

Conclusion

The align-content: flex-start property is useful for aligning multiple rows of flex items to the top of the container, leaving any remaining space at the bottom.

Updated on: 2026-03-15T13:10:57+05:30

200 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements