bugl
bugl
HomeLearnPatternsPathsSearchPremium
HomeLearnPatternsPaths
Learn/CSS/Modern Layout
CSS•Modern Layout

CSS Grid Items - Alignment

Grid items can be aligned within their respective grid cells using properties like:

  • justify-self - Specifies the horizontal alignment within a cell
  • align-self - Specifies the vertical alignment within a cell
  • place-self - Shorthand property for align-self and justify-self

These can also be applied to all grid items in a container using justify-items and align-items on the grid container.

The CSS justify-self Property

The justify-self property is used to align a grid item within its grid cell in the inline direction.

Tip

For pages in English, inline direction is left to right and block direction is top to bottom.

This property can have one of the following values:

  • auto (default)
  • normal
  • stretch
  • start
  • left
  • center
  • end
  • right

Note

For this property to have any alignment effect, the grid item need available space around itself in the inline direction.

justify-self

The CSS align-self Property

The align-self property is used to align a grid item within its grid cell in the block direction.

This property can have one of the following values:

  • auto (default)
  • normal
  • stretch
  • start
  • end
  • center

Note

For this property to have any alignment effect, the grid item need available space around itself in the block direction.

align-self

CSS Grid Item Alignment Properties

PropertyDescription
align-selfAlign a grid item within its grid cell in the block direction
justify-selfAlign a grid item within its grid cell in the inline direction
place-selfA shorthand property for align-self and justify-self

Previous

Responsive Web Design - Templates

Next

CSS Grid Items - Order

This chapter

Overview
24

Lessons

64m

Read time

1. CSS Flexbox2. CSS Grid Layout3. Responsive Web Design4. CSS Flex Container5. CSS Grid Container6. Responsive Web Design - The Viewport7. CSS Flexbox justify-content8. CSS Grid Tracks9. Responsive Web Design - Building a Grid View10. CSS Flexbox Align11. CSS Grid Gap12. Responsive Web Design - Media Queries13. CSS Flex Items14. CSS Grid Container - Align Grid Content15. Responsive Web Design - Images16. CSS Responsive Flexbox17. CSS Grid Items18. Responsive Web Design - Frameworks19. CSS Naming Grid Items20. Responsive Web Design - Templates21. CSS Grid Items - Alignment22. CSS Grid Items - Order23. CSS 12-Column Grid Layout24. CSS @supports Rule

On this page

The CSS justify-self PropertyThe CSS align-self PropertyCSS Grid Item Alignment Properties