I'm reading the comments and I think there's a lot of misunderstanding about what CSS Grid is. Mostly because the spec is big and there's not just one way to do things, so it gets mixed with flexbox and tables.
I recommend watching last year's Morten's CSS grid presentation[1] as it has convinced me to stop using other layouts/frameworks and just embrace grid, which is truly amazing and it has been a blast working with it and making responsive websites without worrying too much about the markup.
Is it still the case that one realistically needs to write their layout in flexbox as a fallback? Last I checked grid support was about 87% globally. I learned grid at one point but then just ignored it on the basis that if I had to write everything in flexbox already, why do both? Would love to know if this is a false assumption.
I think the point is, you have to write the fallback anyway. There really is no "enhanced", as they are two different ways to reach the same solution. The user won't notice a difference, and no sane person wants to do the same thing twice just because one method is slightly cleaner.
This is why CSS grids have been a nonstarter for most of us.
It depends if your use case accepts that a site can look different in older browsers. You don't have to write a fallback if people are okay with that.
If your project's stakeholders are prepared to accept that IE 10/11 users won't see the same as Chrome users (I use, “in the same way that those on mobile won't see the same as those on desktop, older browsers such as IE 10 will also see a simpler layout”), then progressively enhancing a mobile layout with CSS Grid is a fine approach.
I accept that this can't always be the case, though. But I don't consider CSS Grid a non-starter for most sites. Browser support is now good enough that I look to use it wherever possible, and try to educate people still stuck in pixel-perfect across all devices -land.
Suzy Grids 2 is float based, a pleasure to work with and covers the old browsers. I'd love to switch to CSS grids but will have to wait another 5 years it seems.
Depending on your use case, you might get away with building your layout for mobile and then grid-ifying it for larger devices. That way those browsers that don't support grid will get the mobile version.
Eleven years ago I was freelance/part-time web developer, specialised in frontend work. If somebody from the future had shown me this comment (quoted below), even though I'd have no idea what "flexbox" or "grid" means, I'd understand, smile and say plus ça change, plus c'est la même chose ...
> Is it still the case that one realistically needs to write their layout in flexbox as a fallback? Last I checked grid support was about 87% globally. I learned grid at one point but then just ignored it on the basis that if I had to write everything in flexbox already, why do both? Would love to know if this is a false assumption.
flexbox was not created for, and should not be used for, page layout. It's to be used for for a series of elements that flow in one direction only and designed for sections of a page, not a whole page.
I've really enjoyed CSS Grid, to the point where I wonder how I ever got by without it. It makes managing complex layouts, or even simple, much easier to manage and control.
While the two have some divergence in what they are intended to solve for, grid-row-gap and grid-column-gap (or grid-gap) are the biggest day-to-day wins with grid. I had a fairly straightforward hack using negative margins and calc() to get spacing with flexbox, but the built-in support for it in grid makes it feel hacky and cumbersome to go back.
Grid's fr (fractional) units also make the old percentage-based format for responsive sizing feel unwieldy in comparison.
You get it. Grid-gap is so powerful and I can never go back to flexbox even for 1-dimensional stuff. My favorite is using minmax() to control responsive overflow.
They serve different purposes, and you'll often want to use both for different pieces of the layout. Flexbox is for laying things out in one dimension, Grid is more for two-dimensional ones.
I really don't get this argument. Not only is it easier IMO to layout things in one-dimension with CSS grid, but there are subtle bugs that occur on different platforms if you have Flexbox and Grid nested within each other. Just stick with Grid all the time and make your life easier.
I just change “flex” to “grid”. It has the same result and it can be grids all the way down. I’ve seen issues on mobile platforms when containing grids in flex boxes.
I don’t write client side browser code these days any more, but when I did back in the 2000s, I remember people bashing using tables for layout, and how everyone should switch to CSS.
From quick googling of what CSS Grid Layout is, seems to be like we’re back to using tables, we just offload it to the style sheet.
I've mostly been a frontend dev since the late 1990s. CSS Grid does feel like building with tables in some respects. You don't suffer the problems tables had though, like the close coupling of layout to HTML, the necessity to have a tag for every cell, the rigid order of cells, or the spacer gifs to stop things collapsing. CSS Grid gives you the formality of a proper grid system with some really nice features for spacing, placement and ordering the content. Plus, in Grid, cells can overlap with other cells, so it's fairly easy to make some really clever designs that look great. It's been very well thought out, and it works.
I really wouldn't want to go back to even plain Flexbox now, let alone floating elements, tables, or any other layout system.
The tables bashing was because of the common view that CSS and HTML, the styling and markup, should be separated. It wasn't due to tag bloat, which has remained common with HTML regardless (we still have a million div tags in the place of table/td/tr).
<table> is a rigid display value taking up an entire tag. So the argument is why not push that into the CSS eg in a div instead and get rid of an entire unnecessary tag. This is why display:table doesn't get the same kind of hate thrown at it that <table> does.
“Tag soup” doesn’t mean “bad markup”. It specifically refers to when you write HTML as a series of commands and the result is a bunch of tags that aren’t nested properly and don’t result in a tree structure. Things like <b><i>…</b></i>.
So they should’ve added new tags for layout, instead of table,tr,td,th ?
Much like yield vs await in Python3 asyncio.
In the Python 2.7 days, people used generator functions to implement async in Python. When Python3 first came out, you couldn’t do both generator and async in the same function. I assume it’s because they used the same mechanism internally.
I think it was Python 3.5 which added support for async generators.
I don't believe python 2.7 could ever do async. Async was only possible in 3.3 when `yield from` landed and then was bastardized into coroutines through decorators.
3.5 released true asnyc/await based on the `yield from` form and then 3.6 allowed for async generators.
You were close and your point remains. Although I don't think new tags are the right choice. I think HTML learnt a while ago that more tags doesn't solve everything.
I do really enjoy python async. It's cool to see a feature develop from a hack like that but a language first approach could have avoided some headaches. This is where Grid wins, it's a fresh take without requiring to maintain backwards compatibility with previous attempts.
I think the philosophical difference is meant to be that in HTML tables the layout was part of the markup (and so had -- or should have had -- semantic meaning) whereas with CSS Grid the table layout is part of the styling. This is alluded to in TFA's section on accessibility.
For devs who don't care so much about accessibility, and are more just interested in getting the layout they want, I guess that argument may not resonate so much. I personally don't care much for taxonomic/teleological arguments around REST methods, but I'm a bit more willing to follow fashion with Grid if it means people on screen-readers will have a better time.
I recommend watching last year's Morten's CSS grid presentation[1] as it has convinced me to stop using other layouts/frameworks and just embrace grid, which is truly amazing and it has been a blast working with it and making responsive websites without worrying too much about the markup.
1: https://www.youtube.com/watch?v=txZq7Laz7_4