justify-content
W3C CSS Snapshot 2026
Distribute remaining space along the main axis after flexible sizes and auto margins have been resolved.
On this page
Syntax and values
| Value or syntax | What it does |
|---|---|
normal | Initial value or initial settings for this property. |
normal / stretch | In flex layout these behave like flex-start. Use flex-grow to let items expand. |
start / end | Aligns to the logical start or end of the relevant axis. |
flex-start / flex-end | Follows the start or end of the flex axis. Reverse directions can change which edge this is. |
center | Centers the items or lines along the relevant axis. |
space-between | Uses equal gaps between neighbors. The first and last sit at the edges when there is free space and more than one item or line. |
space-around | Uses equal interior gaps. Each outside gap is half as large. |
space-evenly | Makes the interior and outside gaps the same size. |
left / right | Aligns to a physical side when the main axis is parallel to the inline axis. Otherwise these behave like start. |
safe center / unsafe center | The safe modifier falls back to start when centering would cause overflow. Unsafe keeps the requested alignment. These modifiers apply to supported positional values. |
Try the example
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>justify-content example</title>
<style>
.layout { display: flex; width: min(100%, 320px); border: 2px solid teal; box-sizing: border-box; }
.layout > div { padding: 8px 12px; background: #def5f5; color: #123; border: 1px solid #81b9b5; box-sizing: border-box; }
.layout { justify-content: space-between; }
</style>
</head>
<body>
<div class="layout">
<div class="first">A</div>
<div class="second">B</div>
<div>C</div>
</div>
</body>
</html>
What to expect A and C sit at opposite edges. Change to center to put the group in the middle.