HTML Academy
The justify-content property: flex-start | flex-end
Flexbox, part 16/32
Back to the list of tasks
  • 1. The display: flex property, flex item
  • 2. The flex-direction property, main axis
  • 3. The flexbox cross axis
  • 4. The justify-content property, alignment along the main axis
  • 5. The justify-content property: flex-start | flex-end
  • 6. The justify-content property: space-between | space-around
  • 7. The align-items property, alignment along the cross axis
  • 8. The align-items property: flex-start | flex-end
  • 9. The align-items: baseline property
  • 10. The align-self property, or selfish alignment
  • 11. The align-self: baseline property
  • 12. Test: Creating a simple palette
  • 13. The flex-wrap property, overflow of flex items
  • 14. The flex-wrap property, reverse overflow
  • 15. The align-content property, alignment of flex container lines
  • 16. The align-content property: stretch and align-items
  • 17. The align-content property: non-stretch and align-items
  • 18. The align-content property, remaining values
  • 19. The order property, the sequence number of the flex item
  • 20. Test: Creating a more complicated palette
  • 21. Perfect centering by assigning margin: auto to the flex container
  • 22. Perfect centering, flex alignment
  • 23. The adaptive horizontal menu, part 1
  • 24. The adaptive horizontal menu, part 2
  • 25. The adaptive horizontal menu, part 3
  • 26. The vertical row of icons
  • 27. The vertical row of icons, part 2
  • 28. The vertical row of icons, part 3
  • 29. Ordering elements with CSS
  • 30. Vertically aligning blocks using a flexbox
  • 31. Test: Complex palettes
  • 32. Summary of “Flexbox, Part 1”
The align-items property, alignment along the cross axis
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

The justify-content property: space-between | space-around

Do you remember the horizontal alignment mode, where the text is arranged evenly within the block and the edges of the text are fully justified to the edges of the block? Just like in this paragraph.

Flexbox has similar justify-content values that evenly distribute flex items along the main axis:

  • space-between — Distances between adjacent items are uniform, and there are no margins between the items and the edges of the flex container.

  • space-around — Distances between neighboring items are uniform, and there is a margin between the items and the edges of the flex container that is equal to half of the distance between neighboring items.

Now we will add a third cat and experiment with these values of justify-content.

So far the result is small. The justify-content property controls the arrangement of items along the main axis, and it has five values:

  • The default value flex-start,

  • flex-end,

  • center,

  • space-between,

  • and space-around.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Even distribution</title> <link href="course.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body class="house"> <div class="room room-1"> <div class="rug rudolf"></div> <div class="rug muffin"></div> </div> <div class="room room-2"> <div class="rug rudolf"></div> <div class="rug muffin"></div> </div> </body> </html>
CSS
.room { display: flex; height: 150px; } .room-1 { flex-direction: row; justify-content: center; } .room-2 { flex-direction: row; justify-content: center; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Add the cat Simba as the last item to each of the .room blocks, meaning add the classes rug and simba to the block.
    2. Set items to be uniformly arranged along the main axis without margins at the edges for the .room-1 block,
    3. and assign uniform arrangement of items with half margins at the edges for the .room-2 block.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.