How to center a div in tailwindcss

Published on Apr 18, 2022

Using grid and flex, we'll center a div element horizontally and vertically on a page.

<!-- by grid -->
<div class="grid place-items-center h-screen">
  Centered using Tailwind.
</div>

<!-- by flex -->
<div class="flex justify-center items-center h-screen">
  Centered using Tailwind.
</div>
CSS