Similarly to flexbox, the source order of the grid items doesn’t matter. To get started you have to define a container element as a grid with display: grid, set the column and row sizes with grid-template-columns and grid-template-rows, and then place its child elements into the grid with grid-column and grid-row. Internet Explorer 10 and 11 on the other hand support it, but it’s an old implementation with an outdated syntax. Basics & Browser SupportĪs of March 2017, most browsers shipped native, unprefixed support for CSS Grid: Chrome (including on Android), Firefox, Safari (including on iOS), and Opera. So I won’t be covering the out-of-date Internet Explorer syntax (even though you can absolutely use Grid in IE 11) or other historical hacks. The intention of this guide is to present the Grid concepts as they exist in the latest version of the specification.
Flexbox is also a very great layout tool, but its one-directional flow has different use cases - and they actually work together quite well! Grid is the very first CSS module created specifically to solve the layout problems we’ve all been hacking our way around for as long as we’ve been making websites. First, we used tables, then floats, positioning and inline-block, but all of these methods were essentially hacks and left out a lot of important functionality (vertical centering, for instance). CSS has always been used to layout our web pages, but it’s never done a very good job of it. CSS Grid Layout (aka “Grid” or “CSS Grid”), is a two-dimensional grid-based layout system that, compared to any web layout system of the past, completely changes the way we design user interfaces.