The Grid code is coming! The Grid code is coming! It’s really, finally coming to a browser near you! Woohooooo!
Whoa, there. What’s all the hubbub, bub?
CSS Grid is going to become supported-by-default in Chrome and Firefox in March of 2017. Specifically, Mozilla will ship it in Firefox 52, scheduled for March 7th. Due to the timing of their making Grid enabled-by-default in Chrome Canary, it appears Google will ship it in Chrome 57, scheduled for March 14th. In each case, once the support is enabled by default in the public-release channels — that is to say, the “evergreen” browser releases that the general public uses — every bit of Grid support now in place in the developer editions of the browsers will become exposed in the public releases. Anything Grid will Just Start Working™®©.
Are those dates an ironclad guarantee?
Heck no. Surprise problems could cause a pushback to a later release. The release schedule could shift. The sun could explode. But we know the browsers already have running code for Grid, and when they mark something as ready for public release, it usually gets released to the public on schedule.
So Grid support in March, huh?
Yep!
How long until I can actually use Grid, then? Two or three years?
March 2017. So about four months from now.
But it won’t be universally supported then!
Rounded corners aren’t universally supported even now, but I bet you’ve used them.
Now you’re just being disingenuous.
Look, I get it. Base layout’s a little different than shaving pixels off corners, it’s true. If you have a huge IE9 user base, converting everything to Grid, and only Grid, might be a bit much. But I’m guessing that you do have a layout that functions in older browsers, yes?
Of course.
Then my original answer stands: March 2017. Because any browsers that understand Grid will also understand @supports()
, and you can use that to have a Grid layout for Grid-enabled browsers while still feeding a float-and-inline-block layout to browsers that don’t understand Grid. Jen Simmons wrote a comprehensive article about @supports()
, and I wrote a short article demonstrating its use to add layout enhancements. The same principles will apply with Grid: you can set up downlevel rules, and then encapsulate the hot new rules in @supports()
. You can retroactively enhance the layouts you already have, or take that approach with any new designs.
Writing two different layouts for the same page doesn’t sound like a good use of my time.
I get that too. Look at it this way: at some point, you’re going to have to learn Grid. Why not learn it on the job, experimenting with layouts you already understand and know how you want to have behave, instead of having to set aside extra time to learn it in a vacuum using example files that have nothing to do with your work? You’ll be able to take it at your own pace, build up a new set of instincts, and future-proof your work.
Can’t I just wait until someone creates a framework for me?
You could, except here’s the thing: as Jen Simmons has observed, Grid is a framework. Using a framework to abstract a framework seems inefficient at best. I mean, sure, people are going to do it. There will be Gridstraps and GAMLs and 1280.gses and what have you. And when those are out, if you decide to use one, you’ll have spend time and energy learning how it works. I recommend investing that time in learning Grid Actual, so that you can build your own layouts and not be constrained by the assumptions that are inevitably baked into frameworks.
Grid sounds like tables 2.0. I thought we all agreed tables for layout were a bad idea.
We agreed table markup for layout was a bad idea, particularly because at the time it was popular, it required massive structural hacks just to get borders around boxes, never mind rounded corners. The objection was that it took 50KB of HTML tags and three server calls just to do anything, and 100 times that to set up a whole page’s layout, plus table markup locked everything into a very precise source order that played merry hell with any concept of accessible, searchable content. The objection wasn’t to the visual result. It was to what it took to get those results.
With Grid, you get the ability to take simple, accessible markup, and lay it out pretty much however you want. You can put the last element in the source first in layout, for example. You can switch a couple of adjacent bits of the page. Questions like “how do I order these elements to get them to lay out right?” become a thing of the past. You order them properly, and then lay them out. It’s the closest we’ve ever gotten to a clean separation between structure and presentation.
Not only that, but thanks to CSS transforms, clipping paths, float shapes, and more, you don’t have to make everything into a perfectly-edged grid layout. There is so much room for visual creativity, you can’t even imagine. I can’t even imagine. Nobody can.
So Grid solves every single layout question we’ve ever had, huh? Layout Nerdvana for all?
Oh, no, there are still things missing. Subgrid didn’t make it into these releases, so there will still be some gridlike layouts that seem like they should be simple, but will actually be difficult or impossible. You can’t style a grid cell or area directly; you have to have a markup element of some sort to hang there and style. All grid areas and cells have to be rectangular — you can’t have an L-shaped area, for example. Grid gaps (“gutters”) can only be of uniform size on a given axis, very much like border-spacing
in table CSS.
You can usually fake your way around these limitations, but they’re still limitations, at least for now. And yeah, there will probably be bugs found. If not bugs, probably unexpected use cases that the spec doesn’t adequately cover. But a lot of people have worked really hard over an extended period of time on stamping out bugs and supporting a variety of use cases. This is solid work, and it’s going to ship in that state.
What happens if Firefox or Chrome pushes Grid back a release or two, but the other ships on schedule?
In that case, it will take a little longer for your @supports()
-encapsulated Grid rules to be recognized by the tardy browser. No big deal. The same applies to MS Edge, which hasn’t caught up to the new Grid syntax even though it was the first to ship a Grid implementation — with different rules, all behind prefixes. Once Edge gets wise to the new syntax and behaviors, your CSS will just start working there, same as it did in Firefox and Chrome and any other browser that adds Grid.
All right, so where can I go to learn how to use it?
There are several good resources, with more coming online even now. Here are just a few:
- The Experimental Layout Lab of Jen Simmons — great for seeing layout examples in action using a variety of new technologies. If you’re laser-focused on just Grid, then start with example #7, “Image Gallery Study”, but the whole site is worth exploring. Bonus: make sure to responsively test the top of the page, which has some great Grid-driven rearrangements as the page gets more narrow.
- Rachel Andrews’ Grid By Example — a large and growing collection of examples, resources, tutorials, and more. There’s a whole section titled “Learn Grid Layout” that’s further broken up into sections like “UI Patterns” and “Video tutorial”.
- CSS-Tricks’ A Complete Guide to Grid — a boiled-down, pared-down, no-nonsense distillation of Grid properties and values. It might be a bit bewildering if you’re new to Grid, but it’s the kind of resource you’ll probably come back to again and again as you’re getting familiar with Grid.
- CSS Grid Layout specification — if all else fails, you can always go to the source, Luke.
But remember! If you hit these sites before March 2017, you’ll need to make sure you have Grid support enabled in your browser so that you can make sense of the examples (not to mention anything you might create yourself). Igalia has a brief and handy how-to page at Enable CSS Grid Layout, and Rachel also has a Browsers page with more information.
I’ve been hurt by layout promises before, and I’m afraid to trust.
I feel you. Oh, do I feel you. But this really looks like the real thing. It’s coming. Get ready.