Help us invent CSS Grid Level 3, a.k.a. "Masonry" layout
webkit.org
webkit.org
The news here is that people at WebKit decided to push the debate to the public, inviting designers and developers to take some action (“post to social media, write blog posts”), in order to get past this.
While it may look just like a formality, I think this will make an important precedent. The real underling debate here is either to treat every layout option as a part of the CSS Grid, or keeping adding new CSS Display proprieties as necessary.
The first option will make even more complex the (already convulsed, IMHO) CSS Grid specs, the latter will bloat the CSS specs with a load of new proprieties (and related sub-proprieties).
Either way, it's not as easy as it looks.
Grid you place everything in the grid first (e.g. an item goes in col:2,row:3), then size the grid. Masonry ideally you want to size the tracks first, then place items in those tracks.
The first Firefox implementation (and the spec at that stage) basically said you don't consider any masonry items for sizing tracks (except for the first row, and some other rules - its complex). This meant that it is trivial to create items that overflow their tracks.
The specification at the moment asks to place every item in every possible track. This has quadratic performance O(N_tracks * N_items) in the worst (and somewhat common case). Quadratic performance is bad[1] and we don't really have this in other layout algorithms.
With nesting introduced the performance goes (sub-)exponential, which is really poor, even if you have a fast CPU.
One may argue that these cases aren't common, but folks always test the boundaries with layout modes in CSS - so things need to be fast by default.
Note: In grid items size themselves differently depending on what tracks you place them in, which is why you need to place in every possible position.
Masonry potentially needs a different algorithm for sizing tracks to mitigate these problems, (the blog post doesn't go into these issues in sufficient detail). There may have been a version of grid sizing which didn't have item positional dependence but that ship has sailed.
[1] https://randomascii.wordpress.com/2019/12/08/on2-again-now-i...
columns: 1fr auto max-content
<!-- items -->
<div>1</div>
<div>somethingsuperlong</div>
<div style="span: 2;">something else</div>
You first need to decide how big each of the three columns are going to be, then you want to place the items in each of the columns.Depending on the non-fixed column type (there are different rules for each type) you want to ensure their constraints are satified (typeically they are big enough to encompass the items).
https://webkit.org/wp-content/uploads/video3-museum-dark.m4v
Mostly, you just write grid-row-template: masonry and everything else just works with it. This is nice. It doesn't become harder to use the grid layout than it already is IMHO.
The drawback is mostly for browser-engine authors, for whom the bar for "fully supports CSS Grid" will be set even higher. They also mention that it might avoid "performance traps" where an implementation that needs to support all features of grid might be slower at some parts of grid layout than it would be if the specification were simpler.
If there were a separate display mode, then you'd have to repeat the grid-column specification for the masonry layout, which seems a shame.
Why? What's the downside to reusing grid-column-template or whatever for the CSS Masonry spec?
A better approach might be to lean on the "grid" naming, but still silo it off via an own display directive (a bit like "block" and "inline-block" have shared properties, but also mutually exclusive behaviours)
So maybe an own `display: flex-grid;` could be an interesting solution?
This separate layout mode would avoid "result-specific" nomenclature like "masonry", and could lean on both flexbox & grid to achieve that look: - using `grid-auto-flow` to set a "masonry axis" & distribution logic - using _either_ `grid-template-columns` or `grid-template-rows` to specify the "lanes" - and to make my frankensteinian display-mashup even worse (or genius! for you to decide), the grid items could in turn abuse `flex-grow, flex-shrink, flex-basis` to control their height/width within the main "masonry" axis
> By using subgrid, we can put the year and catalog number on the right of each card — and line up this data for one painting with the same data for the other paintings.
The downside is that all the parts of grid that might be useful in masonry would have to be duplicated in slightly different ways.
This together with the fact the the only two current implementations use display: grid
If it is possible to make them perfectly compatible then the main negative side
It's worth noting this is not the first time things like this have gone to the community for feedback. They did the same for nested CSS selectors, which ended up working quite well feedback-wise: https://webkit.org/blog/13607/help-choose-from-options-for-c...
And exploring the tradeoffs might lead those exploring to reconsider their preferences going in.
Not directly related to the topic, but I recently did some prototyping on a second iteration of an interface with a similar tension—proliferation of similar but distinct types in a data model, or expanding the set of nuances within each existing type to support refinement within it. Going into that prototyping session, I had a very strong bias in favor of the latter. But after exploring the options, I found it vastly simpler to consume the “bloated” interface, and to reason about the resulting application code consuming it.
I don’t have strong feelings on the topic as it applies to CSS masonry, but I suspect there could be similar surprises in how people think about this tension intuitively versus in practice.
And while I think CSS in particular will have a hard time justifying “bloat” (proliferation of use case specific semantics), I think it’s possible that users do tend to find more difficulty using CSS’s denser APIs (like grid).
I've been testing it since last year on FF and Safari and have no complaints about their implementations. I know some people are sniffling about the placement and naming of the properties. You have to be pragmatic about it, though, and realize there probably isn't a perfect solution and just implement it.
I refuse to use JavaScript for the fallback, so the fallback is a lot of ugly CSS that doesn't order things in the right way, but it doesn't make a big deal of trouble for the project I'm working on. Most people will fallback to JavaScript right now, though, and when JavaScript is your solution to layout then you're already on a loser.
This is one of the layouts that were just impossible in CSS and we really need it soon. I also needed the feature they talk about with the background colors for css grid tracks in 2012. I solved that with DIVs, but it was hard to make it responsive.
I'm guessing this was going to be "properties"? It kinda looks like "proprietary" instead, so let's double down on that - I propose "display: tetris;"
.masonry {
column-count: 6;
column-gap: 10px;
}I like grids for pages with content and documentation and such. I don’t like grids for pages of media or other creative content. Cards, flex box, grids, these are all design framework choices and shouldn’t be in CSS spec. We were totally fine with position relative and media-query centric widths and heights. I get that it’s easier to standardize if grids are part of the standard but I miss the days of pages having some creativity in their design. Every site looks the same nowadays.
And before I get downvoted. I have a degree in graphic design. I love CSS and I love the web. Bring back the fun.
I’m a designer who codes, and CSS Grid has completely transformed (and simplified) my approach to responsive web design, and enabled much more complex layouts as a result. Just because a layout was possible before doesn’t mean it was easy.
By all means do things the old way if you want, but to suggest that it would be better if it didn’t exist is insane.
I’m also not advocating to bring back tables and invisible spacer gifs. We have margins and padding for that. Even borders…
main.books {
display: grid;
grid-template-columns: repeat(auto-fill, 180px);
grid-gap: 1rem;
justify-content: space-between;
}
That will make the child items 180px wide, repeat as many children in a row as needed to fill the width with a gap of atleast 1rem extended so that the items are justified to the left and right and are spread evenly. The last row has however many children are left with those children positioned to match the rows above.Before position and float madness and all, we used to abuse tables -- because layouts for complex information do work best in grid systems. Now CSS finally has a module that serves this purpose, and brings a huge amount of flexibility to make formerly painful stuff easy.
I'm not even talking about "page layouts" as a whole, just simple particle patterns like "a big icon with a title + description to it's right" is so so much cleaner and easier to do in markup AND css with grid.
Embrace the tools, and if you dislike them - you may as well just not use them. But thinks like grid make simple, stupid, deadlined webdesign _work_ so so much less of a grind.
(speaking as a General Graphic Designer who's also been deep, deep in CSS since before 2.1)
The reading order you’d expect: https://temp.chrismorgan.info/2024-04-23-masonry-megamenu-2.....
What the demo actually gives you: https://temp.chrismorgan.info/2024-04-23-masonry-megamenu-1..... This affects correct reading order and tab indexes. Basically, sighted users will always read things in the “wrong” order. This just drives home that there is no structure, it’s just an unstructured bag of links. Except… actually if you go through them in numbered order, it looks like there was some fairly logical ordering. It’s just been utterly demolished by inappropriate masonisation.
(I’ve turned on “number items” in those screenshots. Normally, it’d look more like normal columns with no backgrounds.)
The way it should be implemented is with columns, but adding `break-inside: avoid` on each section, which their demo has missed.
The newspaper demo is also a little dubious for similar reasons, but it’s a much smaller deal.
Now images and such media which are in more independent blocks and where reading order isn’t such an ingrained thing, masonry layout does work better there. There are still patches where things can be a bit iffy, mostly around tab indexing, but it’s not obviously wrong any more.
What's the "visual line" in the first example? It goes 1, 2, 3, 4; then down to 5; then a sudden break in the line as it jumps over 3 to the left to reach 6?
Are we supposed to mentally sort the boxes by the top edge coordinates before reading? That would almost make sense of the second example, except that it doesn't explain why 9 comes before 10. Maybe sort by the coordinates of the bottom edge instead? But then 5 should be first. How do I read this thing?
Edit: Actually box 9 seems to start 1 pixel above box 10, so sorting by top edge does work! So a sighted reader simply has to zoom in to the pixel level and carefully measure the coordinates of all the boxes to find the reading order.
Trying to do this with the "masonry" was horrible. What direction do you go in? Horizontally? Then how do you track which elements belong in which row, where you've already been? They're all interleaved. Vertically? Have fun scrolling down and down and down forever as the page loads more and more content dynamically. No, neither of those is how you're meant to engage, you're supposed to simply sit quietly and look at the big wall of pretty pictures.
Giving designers a non-javascripty way to do it is nice, I guess, but I really hope the effect is that the bad layouts we already have are at least better executed technologically, rather than that the better technology encourages designers to use bad layouts more often.
If the order was important, you would use a 1D or 2D layout.
I’m saying that masonry is risky if you’re using it purely visually, specifically because it’s purely visual. It’s the same deal with the CSS `order` property: it can be useful, but you have to be careful not to break expectations.
CSS is almost purely visual. There are a few cases where it influences the accessibility tree (e.g. `display: none`, `speak-as`, `appearance` in some user agents), but never in anything like order.
There I realize that masonry mainly works when your cells have such different heights that to grid-align them creates a lot of vertical dead space. Images and news blocks with images make sense for masonry for this reason and it feels good.
But text-only cells where the cell heights don't differ much, they seem better without masonry. The megamenu demo also works much better as a normal grid because they start with a header so grid alignment lets you scan the headers left to right easily.
A text-only newspaper could make sense with masonry because you aren't trying to navigate relationships between the items, and presumably the content can vary the cell height a lot.
In each case it'd look much nicer with a proper masonry layout but it's still very usable otherwise (and of course you could feature detect to provide a better fallback if you're not happy with that anyway).
I just wish there was an alternative to the default masonry ordering, which afaik is a simple rule that goes sth like 'place the next item in whichever column it can go up highest'. This means that the left-to-right order is really juggled from the second row onwards. What I imagine would be really nice is if there was a layout that preserves more of the left-to-right (or right-to-left, if that's your preferred direction) reading flow. Something like 'put the next item one column to the right of the previous item (or in the leftmost, if you were at the rightmost), unless you can put a second item in the same column without the new bottom going too far below the bottom border of the column to its left'. This would be more flexible than strictly going left-to-right (which would also mess up alignment) and would reatin some meaning of the left-to-right reading direction.
I know it won't be possible to accommodate every possible formula one could prefer for masonry, but if you have content where the ordering matters at least a bit (maybe not for Pinterest, but for a journal eg it would), then I really think sth like this would be a more sensible default than the classic masonry rule.
In a magazine-style layout, wouldn't you read the columns top-to-bottom first, then left-to-right? You can accomplish that already in CSS with either 'columns' or vertical flexbox.
Another issue with this 'masonry' layout is the ragged edge at the bottom. In a magazine that would presumably be justified -- again something you can do with columns or flex.
On the web, I guess there's a hidden assumption that you'll have endless scrolling content, so it doesn't matter what the bottom of the page looks like? If so, that's not necessarily something that should be encouraged.
{
/* Move element a maximum of 2 columns left or right on update */
grid-template-max-horizontal-shift: 2 col;
}For example if there's a gap that needs filling that Is 3 spaces away
Are there any books or papers on how to create a coherent layout system?
What about alternatives like Qt, Tk, SwiftUI, etc.? I've never used anything besides CSS. Are any of the actually-implemented systems in the wild better? If so, what makes them better?
I want a system that provides a better interface for developers, but how? If we could start over, what are the design principles?
I think flutter and XAML might be other interesting ones to look at
Things which are 3 lines in CSS are hundreds of lines of a combination XAML/.NET only to get janky window resizing behaviour.
As I've been thinking about this, I do wonder if starting with grids as the foundation would have been a better approach. As I understand it, early CSS focused on stuff like color and font style, with primitive layout tools. Over time better tools have been bolted on, but it's messy.
Say we merged flexbox and grid into a unified system, and threw away the other layout algorithms. At the same time, made some tweaks to clarify margin, border, padding, and overflow. Maybe that's a good foundation.
I think the big change will be better support for hierarchical definitions, including but not limited to nesting. TFA discussion would be pretty moot if there were namespaced properties that could somehow fit under display: masonry; rather than polluting the global namespace.
I don't want to be overly negative, but I just can't view CSS as "pretty great."
I appreciate the inherent difficulty of using 1-dimensional static text to specify a 2-dimensional dynamic layout. Still, basically every programming problem involves defining abstractions over some domain concept and expressing that in the syntax of your programming language. Somehow that's harder in CSS than any other language I've used.
Within web dev I find both HTML and JS much easier to work with, despite their imperfections.
I have a website with my photos, which doesn’t use any JS for layout. When I was making it, I considered using JS masonry libraries, but I wasn’t satisfied with the results. Proper masonry layouts which fill all available space in practice actually crop some images. Leaving space around photos is required when you don’t want cropping and want to preserve aspect ratio. The only way not to do that is to have infinite scroll, which I guess is what corporate addiction machines want, but that’s not what I want on my own website. Here is what I did:
https://yakubin.com/photography/albumless/
https://yakubin.com/photography/album/kenya-2023/
I used display:inline-block to achieve this result, effectively treating photos as text that needs to reflow into new lines. I’m very satisfied with the result and prefer it over what the masonry libraries do.
The problem is ordering. The current CSS-only solutions work fine as long as the order is not important. (though you will still end up with weirdness at the bottoms of the columns IIRC)
Not just Firefox, the proposal here is
grid-template-rows: off;That's good to know.
display: grid;
grid-template-rows: masonry;
This is however limited to webkit. I implemented it and ditched in October 2023 already for my private news feed in gallery mode.I have it behind a CSS test for the existence of the CSS property so it is only enabled if the browser supports it.
I’m not sure a constraint based system would do much good as it would sit awkwardly in the middle of grid and JS.
Prolog would beg to differ.
It would be a bit like saying a language with iterations but neither first-class functions nor recursion is Turing complete as long as an external stack is provided. Or maybe it allows a stack (or recursion) but requires external intervention for function application.
Cool hacking nevertheless.
The last image has it turned off.
Also, I think the need for masonry is vastly overestimated or perhaps not fully researched. It is presented/implied to be a common need but it isn't. Check the top 100 websites, check your personal top 20 websites, how many use masonry? I bet not that many, it's niche use case which also has plenty of usable alternatives. It also never even shows up in any developer surveys.
Anyway, if we're into the game of building very specific layout solutions into CSS itself now, I'd argue the layout as seen on Google Image search is the far more useful one. It is somewhat of a horizontal masonry, but not really. Each image must keep its original aspect ratio (no cropping) whilst all images on the same row have the same height, thus filling the vertical space of the row fully. At the same time, rows must be roughly of the same height. There can be no gaps at the end of a row nor at the last row.
Quite hard to implement, although there's articles describing how.
When I was cutting my teeth in web design, the early webkit blog and safari releases were always inspirational. The rate at which they pushed out new features in the mid 00s was astonishing
1) Fixed height rows: lower information density (excess white space around some of the items), but easier to scan systematically
2) Masonry layout: higher information density (no excess white space around items), but harder to scan systematically
Nobody is “right” here, it’s simply user-by-user preferences about what you prefer.
with flexbox - I use this tool to streamline the process: https://flexboxcss.com
After reading through the article, I’m convinced it is the right path forward, allowing masonry layouts to utilize the same APIs and properties (columns/rows, gap, etc.) as CSS Grid.
This would lower the bar of entry by using familiar APIs and allow simpler switching between masonry and other column/row setups responsively.
```css .example { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); grid-template-rows: auto; @media (width > 500px) { grid-template-rows: masonry; } } ```
It has some use cases but for the most part it's literally a wall of unstructed information. Difficult to parse and build any mental hierarchy.
It's also ... incredibly easy to do with existing css.
care to demonstrate? given a dynamic collection of images where you don't know the aspect ratios beforehand
Where it gets more complicated is getting them all to align horizontally at the bottom, which even this proposal doesn't do. Pinterest, of course, solved this by not having a "bottom."
In the photo demo all content is either 1-column or 2-column wide - and that already results in some very noticeable gaps. I don't get the impression that it can properly handle arbitrary aspect ratios. You're pretty much forced to stick to a single column width and fit all images to match, so not exactly an improvement over what we already have right now.
https://yakubin.com/photography/albumless/
https://yakubin.com/photography/album/kenya-2023/
Proper masonry layouts which fill all available space in practice actually crop some images. Leaving space around photos is required when you don’t want cropping and want to preserve aspect ratio. That’s why I prefer my solution over what JS libraries for masonry layouts do.
In the megamenu demo the multicolumn layout is pretty much indistinguishable from masonry. The only thing wrong with it is that it allows column breaks in the middle of content. That doesn't need masonry to fix it.
In the newspaper demo the multicolumn layout is actually better, because that's how newspapers work. The masonry demo becomes an unreadable mess.
The museum demo almost feels intentionally mis-designed. The CSS Grid 1 layout obviously has issues, but it could've easily been solved by pulling the nav bar out of the gallery, and using a multicolumn layout for the gallery instead.
So that leaves the Pinterest-style photo gallery. Sure, it's objectively better if you want to achieve this kind of style, but it's an outdated design with horrible UX. Why is it special enough that we need explicit support for it in the standard?
Out of curiousity, why don't browsers have pluggable layout managers? Like Java's AWT/Swing LayoutManager. [1]
Fussing with CSS and Java's stock layout managers (gridbag, table) always fills me with frustration and anxiety. In my experience, for the fussy work, it's easier to explicitly code what I want.
Ages ago, inspired by Designing Visual Interfaces [2], I made a layout manager [3] for canonical design grids [4].
It was pretty neat. Fluent API. Always visually correct. All the baselines aligned just so. Predictable results. Perfect for banging out CRUD forms. [5]
1/ https://docs.oracle.com/en/java/javase/21/docs/api/java.desk...
2/ https://www.amazon.com/Designing-Visual-Interfaces-Communica...
3/ https://web.archive.org/web/20110302212909/http://java.net/p...
4/ https://web.archive.org/web/20110308034949/http://designgrid...
5/ https://web.archive.org/web/20110515182322/http://wiki.java....
Edit: reading further, I think my approach was basically the same as theirs near the end of the post!
Usually what is expected is that with narrower screen, you get fewer columns, pictures are still same-ish size. You also need to keep the order of the items (e.g. on a wider screen 1, 2, 3, 4 are all on one row, with a smaller screen 1 and 2 are on a row, then 3 and 4 on another row).
Like: Given these images, and this window size, here's a calculated layout to make them all look nice...
I figure this would be more performant than any type of JS polyfill
To my mind flexbox could be a basis for masonry way better than grid with less overhead.
I also think mosaic would be a better name.
Would it instead be possible to exclude anyone with that attitude from a discussion about an open standard? I know this sounds toxic, but I would argue that approaching public design this way is ultimately more toxic wrt the outcome and those affected by it.
Or maybe I misunderstood that part since everyone seems to not be bothered by it at all here...
That attitude is rather critical and important to the discussion.
I don't think it's the browser, or the standards bodies, responsibility to have built-in support for every possible feature we can imagine. Instead, the standards need to be simple and extensible so that that libraries (Javascript or WASM) can do creative layouts. (IE, instead of waiting for Masonry layout in CSS, you should be able to grab a Masonry layout library and include it with your web site.)
Otherwise, we're building a system where the standards (CSS in this case) are so complicated that it's getting harder and harder to implement the standards; and are too inflexible to support what tomorrows' developers can imagine.
Otherwise your browser(standards) might become too complex.
I need masonry layouts a lot and tend to be on the "we don't need another display class" side in this debate. But that's unrelated to my "rant".
CSS is already very complicated. Adding more options needs proportionally strong justification.
I'm not claiming this is the case with the Mansory layout; I just understand that adding unnecessary complexity for a small target user base is a valid concern.
How are potentially thousands of niche websites less of an argument than "instagram and co don't need it"?
This take is imho dangerously conflates personal taste and motivation with "should a heavily generalized and clearly purposed layout system be complicated with some magic keyuword options to serve your specific intents?", and misappropriates the assumption that people like and use this form layout as a reason to approve the latter.
This is a standard that affects billions of people and many implementations. It’s great to ask if something is really needed or if it’s just adding bloat.
We shouldn’t just grow the standard without first asking if the growth and added complexity carry their own weight. If someone proposing something can show that, then wonderful.
But yeah, just straight up trying to block these people from being able to ask these questions totally is toxic. As long as they’re asking and participating respectfully there’s no need to be a jerk toward them.
The blink tag was used by well-known website and it's universally recognized as a bad decision.
But what is not fine is trying to exclude people from the conversation and silence them just because you have a disagreement.
But after seeing this I should switch to using CSS. Didn't put too much thought into it, but when I realized it wasn't immediately simple in CSS grid just did it in JS.
My order doesn't super matter but I do like to maintain it. I tried for a long time using CSS columns but I didn't have good luck with that either, though I can't remember exactly why
It is simple, intuitive, it works for all cases. Instead we are inventing, what, the fifth generation of CSS-layouting now? Does nobody think this is odd?
It's only a fixed 2d arrangement. It isn't any more expressive than the CSS table layout or position absolute+relative combos. It has no ability to react to size constraints in any other way than naive stretching and hitting min-width hard. It can't do anything "responsive" like wrapping items to the next line, or switching a grid from 1x6 to 2x3.
You can't make masonry in autolayout constraints, other than precomputing specific constraints for every item, which won't automatically reflow the items to a new container width.
Masonry layout doesn't form a grid, but multiple columns with a variable item height.
I feel like this should not be a part of CSS spec, and absolutely not a part of CSS Grid.
But yes, more powerful "client side" layouting functionality would be very welcome so we wouldn't have to wait the commitees for a decade to center an element etc. And there is the "Houndini" project to get this going, but the browser support is still extremely poor: https://houdini.glitch.me/
You'd rather maintain all the maths and JS dependencies for this than have browsers just render what you want?
It's obviously not viable to implement literally every single design imaginable straight in CSS. If I want to do something silly like placing my content on the faces of a hypercube it wouldn't be realistic for me to expect that to be part of CSS. Having me write some JS is completely acceptable - that's what it is for, after all!
It's not a matter of "would this be better in CSS", the answer to that is painfully obvious. The relevant question here becomes "is this common enough that it warrants a CSS implementation". And honestly? In the case of Masonry I am not convinced it is.
The argument is that the popularity of the layout in contexts where it's possible is a strong argument for enabling it on the web as well. This is not a layout that they just thought of and are trying to invent.
Honestly, I'd say kudos to the WebKit folks for opening the discussion and being transparent about the process and the tradeoffs. It can certainly help refine (or inspire) future proposals.
But maybe it’s just a few dozen more properties and mini-DSLs away this time! Pay no attention to those sirens and false prophets who still believe in anti-CSS “tell the computer how to do exactly what you want” programming…
I can't stress enough how important this is for content experiences. Your content must display reasonably before all bells and whistles load, and when the bells and whistles load, your content had better not shift dramatically (ideally not at all).
This is where a proper solution to this problem shines: After all, when you are on mobile (at least 60% of your users), they will get a single column anyway. Any solution that doesn't solve for them is a nonstarter.
That being said, it is the slow loading of JS and the folks using truly modern browsers with JS turned off that are more common, and for those people this isn't a problem.
But, I think it's really the ONLY problem, and if you solve that problem, doing this stuff in JS would be the right answer. You'd be much more likely to get consistent behavior everywhere, without browser-specific quirks.
And part of the solution exists already! JS doesn't have to block the main thread any more, because you have things like Web Workers and WebAssembly.
Rather than adding another specific layout type, we should add a general-purpose way of hooking into the layout engine from a background task.
Update to add: just saw from another comment in this thread that there's already an effort underway to do this, called Houdini: https://news.ycombinator.com/item?id=40130487 Cool!
There is no logic of js required to do handle whatever screen resize.
But I think, and I hope, that people aren't the fools she's taking us for, and can see how absurd her proposition is.
You could basically clone the grid specification, if you want all those features, and that way both can be developed with what works for each. She says doing that means new grid features might take more time to come to masonry. Really? More time than having to deal with new grid features that won't work at all with your version of masonry integrated in grid? You're still having to deal with two layout systems, even if you want to disguise one of them. Except doing it your way you can't select which system gets the features that work with it.
At the end, instead of two layout systems with two complete sets of features, we'll have one single layout system with a bunch of features that sometimes work and sometimes doesn't, depending on a particular value of a particular declaration that you'll have to know about. And that's why people hate CSS.
Seems lazy and an absolute mess to maintain. And it doesn't make sense at an intuitive level, since masonry works similarly to flexbox, not grid; and it doesn't make sense at a logical level either, since a masonry layout is not a grid.
But I guess this is what we'll end up getting, since apparently anything Jen says goes. Like the ridiculous idea of doing "CSS4", which means nothing, does nothing and is nothing, but we're going with it for some reason anyway.
This is a very uncharitable way of reading this, and that's a polite way of describing this view.
She shows what is possible, and how existing grid mechanisms can be leveraged for masonry layout. It's implicit that coming up with a proposal outside the grid would need to accommodate the same capabilities somehow.
How is it patronising or disingenuous? They (and Firefox) literally implemented this and are showing what is possible. And are asking you for input. If you think you're incorrect, you can join and show them the error of their ways:
--- start quote ---
Our hope is that web designers and developers chime in (post to social media, write blog posts) with your thoughts about which direction CSS should take.
Some people, including those of us at Apple, like having “Masonry” be part of CSS Grid. We believe this functionality is a mechanism to expand CSS Grid — allowing it to finally create columnar grids as well as modular grids. And we want this functionality to be mixed with all the other features of Grid, including the powerful options for defining a columns, track spanning, explicit placement, and subgrid.
Other people instead believe Masonry should be its own separate display type. At first glance, defining Masonry with a new display type might make a lot of sense. You do get a tidy separation between layout types.
--- end quote ---
If adding columnar grids to CSS Grids doesn't make any features impossible, then I don't see why we shouldn't just have one CSS Grid standard, and thus always ensure feature parity between modular and columnar grids.
The argument being portrayed by Simmons, as I understand it, is that every feature that currently works for CSS Grid's modular grids, would also work for a columnar grid.
Without that I cant think of an "easy" to implement formula to keep each column the same length.
If given a group of numbers, how would one divide them into 8 groups the same size?
Extra fun: You may increase each number by n in order to make each group exactly the same size. n must be as small as possible.
OK, having read a lot more, here's my thoughts.
I love the possibilities that can be raised here when masonry is built into grid, but you can target specific rows and columns for specific elements in grid. This is a useful thing for some layouts, but when the rows are truly non-existent (unlike the related auto fill/fit stuff we've had until this point) I feel like the abstraction begins breaking down. As much as I love that we have Apple pushing to get this done, I do think it is probably better to go with a net new masonry display type :-/
But grid is already extremely complicated, and so easy to get wrong it's a meme at this point. Creating even more confusion about how it's fundamentals work feels like the wrong path :-/
It seems like either these constructs are poorly designed, or people don't see how to use them to get what they want.
If you just plop your items into columns, the first items will all appear in the first column and the last items will all appear in the last column (left to right), which is not the behavior you want.
To my knowledge, the correct behavior cannot currently be created in CSS alone. (Or if it can, it must be a wild hack.)
This feels like "I want my layout algorithm to be part of the standard." and if you don't think so, see the part where they also want the equivalent of "colspan = 2" for some itmes - possibly with another pattern to define which ones.
Would you really want that to trigger an entirely new set of SQL statements ?
I mean, yes... it's a very common layout algorithm so it gets standardized
I find it amusing that they've decided to refer to this as masonry layout. If you actually built a wall like this (as opposed to uniformly-sized rows, without any columns) it would be a structural engineering disaster.
> But do expect the name of this value to change in the future. And perhaps prepare for a future where we call this “columnar grid” or “Grid Level 3” instead of “Masonry”.
It's a pretty common descriptor in the Wordpress world - grids/scrapbooks will often have masonry as one of their layout styles. Maybe 100 years from now when people are browsing in their neurodisplay they'll be able to think "masonry" and have their photos tile the way they like, never having heard of Javascript or CSS in their lives. Language is neat like that.
Since bricks have some tensile strength, but mortar (the 'glue' between rows and columns) has ~none, that means that, if you must have lines of weakness, you would prefer they be horizontal than vertical.
On the other hand horizontal masonry is constructed very differently: Flickr fits thumbnails into a row until it reaches some predefined total length, then scales everything down slightly so the total row width matches exactly (resulting in rows of different height). Deviantart does something similar, but shuffles the images for better fit so that the different row heights are barely perceptible.
The reason you think it would be a disaster is the load of gravity against it, a concept they have not yet introduced into CSS, thankfully.
More seriously, what you describe is quite doable with flexbox (flex-direction: row, flex-wrap: wrap and flex-grow: 1).
Interestingly, even the Masonry layout was already doable using a simple multi-column layout, the "only" issue is that instead of having the items left-to-right, top-to-bottom (ordered by row) you have them top-to-bottom, left-to-right (ordered by column) which is not what you want most of the times
It's infuriating.
They haven't decided this. Keep reading!
TL;DR:
Perhaps the best syntax could be grid-template-rows: none; to convey “please do not give me any rows”. Sadly, it’s too late to use this name, because none is the default value for grid-template-* and means “please give me only implicit rows, no explicit ones”.
Instead we could use the name off to convey “please turn off the grid in the row direction, and give me only columns”.
grid-template-rows: off;
But do expect the name of this value to change in the future. And perhaps prepare for a future where we call this “columnar grid” or “Grid Level 3” instead of “Masonry”.But I agree that it's not a good adjective because I had the exact same first thought. Both "natural" and "stonewall" would be better, and they're not great names either.
[0]https://duckduckgo.com/?q=natural%20stone%20walls&ko=-1&iax=...
In my opinion, thinking of this as a grid is misguided. It's barely different than flex columns. I would want to be able to have some objects take up more width than one column, or not have clean columns at all. Like "space filling" and "mosaic".
But anyway, I think the second last section on the link, the part that addresses the wrongness of the name, would align with your opinion.
A name for the inverse I suppose
They’d just created a single program, call it the “Central Software System”, and defined thousands of properties that let you control its state machine to produce the output you need.
Presto! The perfect computer. If for some reason someone needs a new kind of output, it can be added to the Central Software System via a friendly decade-long committee process.
And if the properties happen to conflict in how they define some output, well, the one company in the world who has actually implemented all of this “open standard” can decide what happens in that case.
It’s incomprehensible to visual designers, incomprehensible to programmers, and incomprehensible to document authors.
On the upside, it provides a massive moat of sunk cost and implicit implementation dependency around Chromium, so at least there’s that.
It's also worth keeping in mind that CSS is sometimes more complicated than it seems like it should be due to accessibility concerns and flexibility. That's why you can take some HTML produced by some part of your system and use it in completely different contexts with totally different designs, entirely as is, just by adding a few different rules.
I've been doing HTML dev since the late 90s and things were infinitely more difficult back in the old days. CSS might have been simpler, but doing complex things required tons of bizarre hacks that also made your design more frail and less accessible. These days CSS has improved to the point where you can do just about anything, and even very complicated effects can fairly easily be deconstructed just by looking at the devtools and poking around until you get it.
CSS isn't perfect, but all things considered I'm not complaining.
But sure, if you want, CSS is a conspiracy theory to ensure the dominance of Google.
Its like if the terminal was actually now mostly a video player and people complaining about how awk and sed are tough to use against video frames.
What I do see here, is one of many cases of "I don't understand it therefore it is dumb because it can't be my fault".
This is just an accident of history and not because CSS has anything that makes it intrinsically better than the alternatives.
I’m not saying css is intrinsically better (what does intrinsic even mean in this case?). It’s pragmatically better than anything else I’ve seen. It’s dead simple to learn and use, and (almost) fully declarative, and degrades gracefully. Just show me a better alternative and I’ll change my mind.
CSS is quite a mess, and I would welcome a backwards-incompatible new layouting system, but all the alternatives out there are a lot worse.
Also as mentioned in the linked article the masonry layout is already possible with JS, no decades-long committee process needed. It's just about standardizing something frequently used.
Billions of connected devices worldwide do indeed run on *nix with a mad variety stacked on top.
When you had enough of using text as the single data structure in a shell, you can start doing the same with a GUI toolkit.
As a firmware engineer who is trying to build a website in his spare time, I find CSS absurd. I’ve found SCSS and Sass make it much more bearable. The ability to represent a hierarchy concisely is awesome.
$ /etc/init.d/initwar start
Starting initwar (via systemd)
Sad sysadmin noiseslook at this, how intuitive, how readable:
grid-template-columns: 14ch repeat(auto-fill, minmax(28ch, 1fr)) 14ch;
just throw the whole grid thing out of the window and get on board someone who can create syntax that wouldn't send you to jump off a cliff and feels like it was made by a fellow human being, not an AI controlled robot.
Until then, these complaints usually cash out into unfamiliarity + assuming it's very hard to understand if you were you trying to understand it.
Declarative UI is a very hard problem, so it's not always going to be `text-decoration: underline`.
If you had showed someone the first bicycle, and it came with 3 differently sized wheels and a spike for a seat, you wouldn't have to provide an "ideal replacement" to know that it was a bad design.
> grid-template-columns: 14ch repeat(auto-fill, minmax(28ch, 1fr)) 14ch;
Browser developers are now reaching for straws to remain employable.
That said the biggest tasks remains:
- Go back to HTTP/1.1 with "One time password" auth.: https://datatracker.ietf.org/doc/html/rfc2289
- Simplify the browser so that it can be compiled in less than many hours on the latest CPU.
- Completely remove the tie-ins to any commercial/governmental entities.
Basically go back to Netscape with some improvements to javascript performance and hardware accelerated rendering of HTML.
Everything else invented in the last 20 years is meaningless. This is valid in most domains: Raspberry Pi is the only real exception.