π What is place-content?
place-content is a shorthand property in CSS Grid that sets bothalign-content (vertical alignment of the entire grid) andjustify-content (horizontal alignment of the entire grid) in one convenient declaration. It aligns the whole grid block when there is extra space inside the container.
π Syntax
Basic Syntax
place-content: <align-content> <justify-content>;If you provide only **one value**, it applies to both align-content and justify-content.
π― Available Values
| Value | Description |
|---|---|
| start | Pack grid at the top/left |
| center | Center vertically and/or horizontally |
| end | Pack grid at bottom/right |
| space-between | Distribute free space between tracks |
| space-around | Equal spacing around tracks |
| space-evenly | Even spacing between tracks and edges |
| stretch | Stretches grid to fill container (default) |
Note
π§ͺ Basic Example
Center Entire Grid
.container {
display: grid;
height: 500px;
width: 500px;
grid-template-rows: repeat(2, 100px);
grid-template-columns: repeat(2, 100px);
place-content: center;
}This will center the grid vertically and horizontally inside a 500Γ500 container.
π Visual Example

π§± Using Two Values
You can control vertical and horizontal alignment separately:
Separate Vertical + Horizontal Alignment
/* place-content: align-content justify-content */ */
.container {
place-content: start center;
/* vertically β start, horizontally β center */
}β‘ Equivalent Longhand
Longhand Equivalent
place-content: center;
/* same as */
align-content: center;
justify-content: center;π§ place-content vs place-items
| Property | Aligns What? |
|---|---|
| place-items | Items inside individual grid cells |
| place-content | The entire grid block inside the container |
Note
π§© Real-World Use Cases
- Centering a small grid inside a large page section
- Aligning product cards in a container with extra space
- Creating evenly spaced dashboard rows/columns
- Positioning content blocks in hero or footer layouts
π± Responsive Example
Responsive place-content
.grid {
place-content: start;
}
@media (min-width: 900px) {
.grid {
place-content: space-evenly;
}
}On small screens β content sticks to the top.
On large screens β content is evenly spaced vertically and horizontally.
β οΈ Common Mistakes
- Trying to use place-content when the grid spans full width/height
- Expecting place-content to move individual items (use place-items instead)
- Applying place-content to a grid item instead of the grid container
Note
π₯ Summary
place-content is a powerful shorthand that positions the entire grid block inside its container β both vertically and horizontally. It simplifies your CSS, improves readability, and helps build balanced visual layouts.
Learn more:MDN Docs π