2023-01-06
2450
#css
Leonardo Maldonado
16436
Jan 6, 2023 â‹… 8 min read

When to use Flexbox and when to use CSS Grid

Leonardo Maldonado Fullstack developer. JavaScript, React, TypeScript, GraphQL.

Recent posts:

How AI Is Changing Debugging With Google Gemini

How AI is changing debugging with Google Gemini

The Google Gemini AI model has integrated AI-powered features to improve the debugging experience in web development.

Emmanuel John
May 23, 2025 â‹… 5 min read
10 Node.js 24 features you're probably not using

10 Node.js 24 features you’re probably not using

The Node.js 24 release included significant updates. Explore 10 features you might not be using yet — but absolutely should be.

Emmanuel John
May 22, 2025 â‹… 8 min read
six CSS animation libraries to bring your project to life in 2025

6 CSS animation libraries to bring your project to life in 2025

Explore six of the best, easiest, most configurable, and convenient CSS animation libraries available in 2025.

Murat YĂĽksel
May 22, 2025 â‹… 8 min read
Understanding Next.js Middleware Vulnerability

Understanding Next.js’s middleware vulnerability

A critical auth bypass vulnerability in Next.js lets attackers skip middleware checks by faking the x-middleware-subrequest header.

David Omotayo
May 21, 2025 â‹… 6 min read
View all posts

18 Replies to "When to use Flexbox and when to use CSS Grid"

  1. Thank you for your explanation, one of the best i found on the internet. I have a concern on the css code for the grid explanation. Thank you and good work !

  2. Great article, explains things well.
    Having visual examples of what your css code would look like on a webpage would make this post pure gold.

  3. Excellent article; too bad it fails accessibility tests; light orange type on a light grey background? Building readable websites is also our responsibility as web developers.

  4. Very nice. I’m definately going to use this to up my layout game. One thing, though.

    You really need to explain what’s going on with column and row values of “x / y”. You put it out there, but you didn’t explain what it means or how it works.

  5. I don’t think that’s the point of this article. The point here is to understand layout using Grid and Flexbox.

  6. This is the best article I’ve read about flex box vs CSS grid so far! Flexbox isn’t the right tool for every layout job, but as you’ve shown, it can often be made to work similarly, Grid too have advantages and disadvantages.

  7. I’ve always thought of grid this way but I wasn’t quite sure. It is really handy to use grid as layout since you can manage your layout much faster and more efficient rather than adding a row/col class to individual elements, which is often how you would work with flexbox.

  8. Thanks for the great article do you mind if i translate this article in korean and post it on my blog ?
    I will not be making any money out of your article make sure have referernce with it

    Thanks

    1. Thanks so much for reading! It’s our policy to politely decline requests to translate and republish our content.

  9. “…another thing that’s very helpful in CSS grid, that we don’t have in Flexbox, is the gap property”
    To my knowledge, Flexbox also has the gap property.

  10. Typo at the Grid explanation:
    “since there are five elements, we’ll have three ‘columns’ spanning the entire container due to the auto attribute:”
    ‘columns’ should be ‘rows’

Leave a Reply