cssfrontend

Centering a Div with CSS Grid

Jan 15, 2026
1 min read
1.2k Views

The quickest way to center anything in CSS.

To center a div both horizontally and vertically using CSS Grid, you only need two lines of CSS on the parent container.

```css
.container {
display: grid;
place-items: center;
min-height: 100vh;
}
```

This is much cleaner than the old flexbox or absolute positioning methods.

Notes: centering-div-css-grid

Date: Jan 15, 2026

Back to all shorts
Spread the word: