30 seconds of CSS

  Back to Home

Evenly distributed children  layout

Evenly distributes child elements within a parent element.

HTML
<div class="evenly-distributed-children">
  <p>Item1</p>
  <p>Item2</p>
  <p>Item3</p>
</div>
CSS
.evenly-distributed-children {
  display: flex;
  justify-content: space-between;
}
Demo

Item1

Item2

Item3

Explanation
  1. display: flex enables flexbox.
  2. justify-content: space-between evenly distributes child elements horizontally. The first item is positioned at the left edge, while the last item is positioned at the right edge.
  3. Alternatively, use justify-content: space-around to distribute the children with space around them, rather than between them.
Browser support

100.0%

⚠️ Needs prefixes for full support.