coding180 icon
Coding180
CSS Grid: justify-content, align-content, place-content attribute

CSS Grid: justify-content, align-content, place-content attribute

Home > Tutorials > CSS > CSS Grid Layout


justify-content property is the horizontal position of the entire content area in the container (left, middle, right), and the align-content property is the vertical position of the entire content area (top, middle, and bottom).

.container {
  justify-content: start | end | center | stretch | space-around | space-between | space-evenly;
  align-content: start | end | center | stretch | space-around | space-between | space-evenly;  
}

These two properties are written in exactly the same way, and both can take the following values. (The following diagrams all take justify-content attributes as an example.

The diagrams of the attributes are exactly the same, except that the horizontal direction is changed to the vertical direction.)

start - the start border of the aligned container.

css grid justify-content start

end - the end border of the aligned container.

css grid justify-content end

center - Center the container inside.

css grid justify-content center

stretch - When item size is not specified, stretches to take up the entire grid container.

css grid justify-content stretch

 

space-around - Equal spacing on both sides of each item. Therefore, the spacing between items is twice as large as the spacing between items and the border of the container.

css grid justify-content space around

space-between - Items are spaced equally from item to item, and there is no space between item and container border.

css grid justify-content space between

space-evenly - Items are equally spaced from item to item, as is the space between item and container border.

css grid justify-content space evenly

place-content roperty is a combined shorthand for align-content property and attribute. justify-content

place-content: <align-content> <justify-content>

Below is an example.

place-content: space-around space-evenly;

If the second value is omitted, the browser assumes that the second value is equal to the first value.


user

Robort Gabriel

Lagos, Nigeria

Freelance Web Developer, Native Android Developer, and Coding Tutor.

Skills
  • UI / UX
  • JavaScript
  • Python
  • PHP
  • Kotlin
  • Java
  • Bootrap
  • Android
  • Laravel