Dan D Kim

Let's share stories

The modern way of centering in CSS

2021-02-01 Dan D. Kimcss

Here’s the more traditional way of centering things with css.

.something {
  display: flex;
  justify-content: center;
  align-items: center;
}

Here’s the newer way of centering things.

.something {
  display: grid;
  place-items: center;
}

Shorter. Cleaner. Gets the job done.

Read more about the place-items CSS property here.


That’s all. Happy coding!