6 ms·
CSS is not a real constraint language. If it really were a constraint language, it would be better. There's no constraint solver. Just a bunch of rules applied
by Animats 8y ago
CSS is not a real constraint language. If it really were a constraint language, it would be better. There's no constraint solver. Just a bunch of rules applied sequentially.
I'd like to have a real constraint system, like the one in Autodesk Inventor sketch mode. You select two things and apply a constraint - parallel, tangent, horizontal, collinear, etc - and the constraint system enforces those constraints. The layout GUI tells you if you've created a conflict. CSS solves an easier problem, and not very well. It's such a mess that no one can attach a decent GUI to it.
Amusingly, tables came back. But they're called "layout tables" now, to avoid embarrassment. Trying to do 2D layout with 1D constructs (the "float" and "clear" era) was just silly.
- _bxg1 8y ago> Amusingly, tables came back. But they're called "layout tables" now, to avoid embarrassment. I'm not really sure what you're talking about. Tables were bad because they were too rigid and weren't designed for layout purposes; they do still get used when you want to display an actual table. Maybe you meant CSS Grid? > Trying to do 2D layout with 1D constructs (the "float" and "clear" era) was just silly. The float era was certainly a dark time, and I'm glad I came into the field on the tail end of it. It was a hold-over from CSS' document-focused origins. Today we have flex-box, which quite elegantly serves 90% of people's layout needs, and CSS Grid which fills in the rest. For the record, flex-box is a 1D construct for doing 2D layouts, and it does the job fantastically. Your Autodesk comparison belies a fundamental misunderstanding about the nature of the DOM - it is, to its great advantage, a 1D space which flows into a 2D shape. In fact, this was the great flaw with using tables for layout in the first place. By making the content fundamentally 2D, all it could do to respond to different screen sizes and different browser window resizes is stretch. But you don't actually want your layout to be totally percentage-based. You want your content to wrap and flow to make the best use of the available space that it can, with no assumptions about screen size or ratio. The web is 1D because text is 1D. As text flows in lines, within containers which may be different shapes and sizes, so does the entire document model. This is profoundly powerful. Modern CSS gives you the tools to make select aspects of your layout work differently - yes, even in 2D ways - but they're best used to shape and guide that fundamental flow instead of replacing it.
- rmetzler 8y ago> Tables were bad because they were too rigid and weren't designed for layout purposes; they do still get used when you want to display an actual table. And when you have to implement a email design someone gave you who think it’s more important to have it look a certain way then to implement it reliable.
- mattkevan 8y agoThat’s because the rendering engines in email software are crap, not due to a deficiency in CSS - I think Outlook still uses Word’s HTML renderer and even Gmail doesn’t support everything.
- worble 8y agoIn all fairness that's probably a good thing. God forbid if emails today were like the rest of the web, hijacking the scrollbar, constant popups to register, like and subscribe. I like my emails like I like my actual mail; text and maybe the odd image.
- pbhjpbhj 8y agoI've got to disagree. Your preference for text emails doesn't mean those who do want rich-text or HTML should have to put up with crappy rendering that requires specialist developers. I don't understand why HTML payloads can't just be loaded in a (streamlined) browser pane?
- mattkevan 8y agoAgreed. Rendering HTML and CSS in a vaguely standards-compliant way is surely a solved problem by now. Javascript should stay firmly blocked though.
- _bxg1 8y agoThey are; it just tends to be a really crappy browser pane that isn't based on (and therefore kept up to date with) any major browser, so writing the HTML and CSS is like being transported back to 2004
- zeroname 8y ago> It's such a mess that no one can attach a decent GUI to it. A very good point. My guess is that we could let designers do a lot more and developers do a lot less, if it wasn't for that impedance mismatch.
- GorgeRonde 8y ago> CSS is not a real constraint language. If it really were a constraint language, it would be better. There's no constraint solver. Just a bunch of rules applied sequentially. > I'd like to have a real constraint system, like the one in Autodesk Inventor sketch mode Here you go: https://gss.github.io/ https://gss.github.io/ > GSS reimagines CSS layout & replaces the browser’s layout engine with one that harnesses the Cassowary Constraint Solver
- mch82 8y agoHere’s the [parent project][1] and the old [research page][2] at University of Washington. The most recent implementation is Rust in 2018. The JavaScript repos are inactive. I’m not sure if that’s because the algorithms are considered complete or because the project is dormant. One of the researchers is no longer at UW and the other is an emeritus professor, so semi-retired. The claim is Apple uses these layout algorithms in Interface Builder. [1]: http://overconstrained.io/ http://overconstrained.io/ [2]: https://constraints.cs.washington.edu/cassowary/ https://constraints.cs.washington.edu/cassowary/
- Animats 8y agoToo bad. That was the right idea. With that, we could have Dreamweaver type layout working again. That project seems to be more about the math than making layout easier. That's a problem with many academic projects. One thing I've liked about Autodesk products is that they often have complex math inside, completely hidden from the user. You see that in the CAD world, where the physical universe has to be modeled.
- mpweiher 8y ago> Too bad. That [constraints] was the right idea. In theory, yes. And the theory certainly can work beautifully as intended in practice. However, developers and designer tend to have huge problems with autolayout. Specifying what you want visually as a set of linear constraints is challenging. It is very easy to get very surprising outcomes, easy to overconstrain and underconstrain. It's a very big sledgehammer aimed at some very delicate eggshells. Not just when it comes to understandability, but also when it comes to runtime performance.
- goto11 8y ago> Amusingly, tables came back. But they're called "layout tables" now, to avoid embarrassment I'm not sure exactly what you are referring to, but there have been some misunderstandings regarding tables. Before CSS, <table>-tags were there only way to control the layout, but since CSS 2, it have been possible to achieve the same kind of layout which display:table in CSS without having to abuse <table>-tags. But there is nothing wrong with using <table> when they are semantically appropriate. Recently CSS have gotten display:grid which is way more powerful than table layout ever was. Float and clear was never intended for general layout. They were invented by Netscape back in the day to allow text to float around images. Float/clear-hacks became a necessary evil in the dark age before IE supported display:table. You cant really blame CSS for IE not supporting critical parts of the spec, since this was part a deliberate strategy by MS to "kill the web". Luckily this strategy failed and MS changed their minds.
- pbhjpbhj 8y ago>Before CSS, <table>-tags were there only way to control the layout // As an historical aside: that's not quite true to my recollection. p-elements had width, height (and possibly other attributes, margin, border?). And empty <p>, hr, br(?), were used for rudimentary layout? Then there was color, bgcolor attributes; and font tags. Not sure when <center> came out? This https://www.w3.org/Style/CSS20/history.html https://www.w3.org/Style/CSS20/history.html is probably much better than my recollection. I started making webpages/email-circulars about 1994-95.
- goto11 8y agoI think you remember wrong regarding P. P never supported width or height or margin before CSS. With FONT-tags and other presentational html you could control colors and typography to some extent, but the only way to control white-space and sizes and margins before CSS was to use tables, typically combined with "spacer gifs". E.g you wanted to indent a paragraph 17 pixels, you created a table with two cells and put a 17 pixel wide transparent gif in the first cell.
- pbhjpbhj 8y ago