CSS Grid Layout and CSS Flexible Box Layout, commonly known as Flexbox, are powerful techniques for implementing flexible grid and column- or row-based layouts with CSS. These two techniques enable designers and web developers to accurately and fluidly position elements and content on web pages and web applications.
While Flexbox (see A Complete Guide to Flexbox by CSS-Tricks) predominantly works along a single principal dimension, called the main axis or flex direction (either row or column), and therefore essentially is a one-dimensional layout technique, Grid Layout (see A Complete Guide to Grid by CSS-Tricks) is a two-dimensional approach that always takes both rows and columns into account when positioning elements.
Another key difference between those two techniques is that Flexbox works from the content out, i.e. it lets the content define how it’s supposed to be positioned, whereas Grid Layout works from the layout in, that is, it starts with the grid and allows you to either automatically or explicitly assign content elements to cells or areas in that grid.
Grid layouts also are more conducive to implementing entire page layouts whereas Flexbox shines when it comes to defining how content in specific page areas is supposed to flow.
While these techniques might seem conceptually simple at first they come with a plethora of features, intricacies, and indeed pitfalls, too. Remembering the various CSS properties involved and their possible values and behaviours can seem like a daunting task. Being able to visualise the resulting layout from just a set of CSS properties only comes with continued usage and experience.
This is where tools come in handy that allow you to generate Flexbox and Grid layouts in a visual editor. Interactive CSS Grid Generator by Layoutit! is such an editor for CSS Grid Layouts. Flexbox Generator by Loading.io is a similar tool for Flexbox layouts.
Both provide immediate visual feedback and HTML and CSS code for you to copy and build upon once you’re satisfied with the result.