News for hackers. Stuff that matters.
Re:CSS: It was twenty years ago today by cousin_it on Friday October 10, 2014 @06:24AM (#8437027)
> In my initial CSS implementation in 1995 I used the “SkyBlue” constraint solver to resolve conflicting style sheet statements. (By the way, “SkyBlue” and “Cassowary” were both developed at the University of Washington.) Having a constraint solver allows you to express relationships between arbitrary elements and have conflicts resolved automagically. However, things can get complex when elements disappear and new ones arrive, like they do through DOM operations. Circular dependencies must also be handled gracefully. Therefore, the idea of allowing CSS to express layout constraints between any elements were dropped at an early stage.

That was the biggest mistake, IMO. John Nagle's comments here [1] express that point really well:

> With Dreamweaver 3 and tables, it wasn’t necessary to look at HTML to lay out a page. With Dreamweaver 8 and CSS, the page designer must understand CSS, HTML, and probably Javascript. That’s was a big step backwards. The CSS system is just too programmer-oriented. And I’m a programmer. (Programmer as in MSCS from Stanford, the Nagle algorithm in TCP, inventor of ragdoll technology, real-time robot vehicle control, not programmer as in “writes some Perl”. And my first web site went up in 1995.) It’s not that CSS is hard; it’s that CSS is bad.

> The worst problem with DIV-based layout is that the layout system is too weak. There’s no form of “grid” layout. There’s no way to relate a DIV to anything but its predecessor, its parent, or an absolute position. The system is just too dumb. That’s why people have to stand on their head just to get three columns to work. Tables actually are a better designed layout system. Table layouts allow table cells which span multiple rows and columns. If all tables could do were simple grids of cells, the CSS approach might make sense, but tables are more general than that.

[1] http://www.raizlabs.com/graiz/2006/09/25/ten-reasons-why-css...

Re:CSS: It was twenty years ago today by robin_reala on Friday October 10, 2014 @07:16AM (#8437165)
That might have been true in 2006 but we now have reasonable support cross-browser for Flexbox[1] (especially if you reduce the pain with autoprefixer[2]), and CSS Grid Layout[3] is coming.

[1] http://www.w3.org/TR/css3-flexbox/

[2] https://github.com/postcss/autoprefixer

[3] http://www.w3.org/TR/css3-grid-layout/

Re:CSS: It was twenty years ago today by Touche on Friday October 10, 2014 @10:08AM (#8437721)
Am I the only one who finds flexbox incredibly complicated? It probably covers every possible scenario but doing some simple thing takes me 15 minutes of trial and error to get right.
Re:CSS: It was twenty years ago today by chc on Friday October 10, 2014 @12:27PM (#8438604)
I would say the opposite: After a small initial hump, flexbox is actually very simple for what it gives you, but it's ultimately fairly limited. It's not up to implementing every kind of grid layout cleanly, and it's not even in the same ballpark as constraint-based layouts.
Re:CSS: It was twenty years ago today by archagon on Friday October 10, 2014 @10:43AM (#8437935)
I'm no CSS expert, but I personally find it incredibly easy and intuitive compared to the usual CSS alignment nonsense. Floats? Table display? Inline block?

Flexbox is the first CSS layout feature that makes me feel like I don't have to harness an army of hacks to get anything done.

Re:CSS: It was twenty years ago today by andrewingram on Friday October 10, 2014 @12:25PM (#8438593)
There are still layouts it can't solve, for which I'm using Javascript to manually calculate the size of elements
Re:CSS: It was twenty years ago today by Bahamut on Friday October 10, 2014 @11:06AM (#8438080)
There's a learning curve, but it isn't as fragile as the set if margin and position hacks that were standard before. Those old hacks are still used for supporting old browsers (IE8 and before), but flexbox simplifies things once you grasp it in applications.
Re:CSS: It was twenty years ago today by biscarch on Friday October 10, 2014 @11:37AM (#8438261)
I find it no more complicated than things such as figuring out things like clearfixes were in the beginning.
Re:CSS: It was twenty years ago today by cookiecaper on Friday October 10, 2014 @08:35AM (#8437364)
While you're right that the current versions of all browsers seem to support it now (though Safari still requires prefixing), it's pretty recent on some of these: http://caniuse.com/#search=flex. Most people still won't feel comfortable using it for probably another year or so, and this is just one element in the Flexbox specification; it doesn't necessarily imply the rest is well-supported or that implementations are reasonably consistent across browsers.
Re:CSS: It was twenty years ago today by acdha on Friday October 10, 2014 @10:20AM (#8437796)
It is recent but I'm seeing >85% of visitors to non-technical sites using a browser which supports flexbox. At that point, using something like a CSS preprocessor to manage the prefixing / older spec support and deploying flexie for older versions of Internet Explorer starts looking like a very reasonable prospect. If your goal is simply to do vertical centering, align elements with consistent sizing, or have the ability to reorder elements in different contexts without having to change the DOM order, flexbox works well in all of the browsers listed at http://caniuse.com/#feat=flexbox.

That said, it is something of a travesty that one of the most popular reasons to dive down that particular rabbit hole in 2014 is to get real vertical centering: https://gist.github.com/acdha/a91a46706de02c37566a is still 11 lines for one of the most basic layout requirements.

Re:CSS: It was twenty years ago today by robin_reala on Friday October 10, 2014 @08:42AM (#8437385)
OK, fair points, but if the OP can look back 8 years and apply that to now then I reserve the right to look forwards 8 years and do the same :)
Re:CSS: It was twenty years ago today by rmc on Friday October 10, 2014 @08:18AM (#8437318)
So it only took 20 years...
Re:CSS: It was twenty years ago today by brandonbloom on Friday October 10, 2014 @03:27PM (#8439575)
...and it's more complicated and less capable.
Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @10:12AM (#8437744)
"Any donkey can kick down a barn, but it takes a skilled carpenter to build one."

What language would be able to support billions of websites coded by millions of developers, rendered on thousands of different types of media and be easier to code with than CSS? Until I've seen a working demo of this mythical styling language, I'll be very grateful for what I've got.

Re:CSS: It was twenty years ago today by cousin_it on Friday October 10, 2014 @11:00AM (#8438037)
The comment you're replying to already contains answers to your points. The complainer mentions his credentials as a programmer, and points out an alternative that exists. You can see that alternative at work by viewing the source of this page.
Re:CSS: It was twenty years ago today by wodenokoto on Saturday October 11, 2014 @08:59PM (#8443938)
If you viewed this on a phone, you'd see that the table based layout is not up for the task either.
Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @11:15AM (#8438133)
It's 2014, and you want to discuss tables vs CSS layouts? Maybe next week we can discuss whether anyone will ever need a hard drive bigger than 2MB.
Re:CSS: It was twenty years ago today by cousin_it on Friday October 10, 2014 @11:34AM (#8438231)
Well, Paul Graham became popular by writing online essays about Lisp, which was invented in 1960 and went out of vogue during the AI winter of the 1970s. Then he started Y Combinator and wrote Hacker News in a dialect of Lisp. If you think old tech is bad, why are you here? ;-)

More to the point, I think the discussion of tables vs CSS is worth reopening, because the original arguments in favor of CSS focused on having clean semantic HTML, and we all see how that turned out. Just go to http://reddit.com/ and view the source, you'll see <div class="spacer"> staring you in the face. So that argument is a wash. As for the specific drawbacks of CSS compared to tables, I think the original comment covered them well.

Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @12:06PM (#8438462)
1. It's pretty easy to find stories of somebody having success using an old technology, but it's even easier to find examples of old technologies being replaced by something better.

2. Finding somebody successfully bashing a nail into a wall with a shoe doesn't mean we should all throw away our hammers.

3. If we get into the drawbacks of CSS vs tables, tables are going to lose. I can think of two situations where tables will win - lack of developer skill (yes, tables are easier to learn quickly), and needing to support old browsers more than new ones. Whereas CSS will win on responsiveness, performance, workflow, third-party tools, features, maintenance, accessibility, flexibility, semantics, and just about every other area of front-end development you care to mention.

EDIT: Here's an article from 2003 (!) that makes the same points. As CSS has improved, the arguments have become stronger.

https://www.hotdesign.com/seybold/03overview.html

Re:CSS: It was twenty years ago today by debaserab2 on Friday October 10, 2014 @01:27PM (#8438990)
I wouldn't really use reddit as an example of quality CSS styling. Yes, it can be used improperly. It can also be used to create clean semantic HTML. Table-as-layout cannot.
Re:CSS: It was twenty years ago today by gdrulia on Friday October 10, 2014 @10:32AM (#8437869)
Totally agree to your point.

I personally don't have much of experience with different layout systems used in other fields, yet what I got from working with ActionScript3 (flex) layout methods few years ago and then recent experience with current android layout system, just brings back the appreciation of CSS.

It might not be perfect, easily becomes complicated, but it works and allows great flexibility.

Re:CSS: It was twenty years ago today by chc on Friday October 10, 2014 @12:56PM (#8438785)
http://gridstylesheets.org/ is CSS with constraints and sugar for things like grid layouts. As easy as CSS in simple cases, but powerful enough to handle more complicated cases that require either elaborate hacks or JavaScript with CSS as it exists today.
Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @02:42PM (#8439378)
Thanks for the link. I need to spend some time looking at this.
Re:CSS: It was twenty years ago today by Someone1234 on Friday October 10, 2014 @10:34AM (#8437881)
Unfortunately in the current climate you're unlikely to see someone even try to develop a competitor to CSS, JavaScript, or HTML.

The problem is that those technologies are all held hostage by at least two inefficient committees, and enough browser vendors have signed on to that to make doing anything without their approval near impossible.

So let's say you had a magical CSS replacement which is perfect in every way, that's ten years in committee which is a back and forward process where they can effectively force you to alter the design for obscure reasons, and then even after that you have to convince every single browser vendor to implement it, and only then FINALLY will it take another ten years for all browsers to support your new syntax so you can use it freely without worrying about incompatibility.

Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @10:43AM (#8437941)
Part of the achievement of CSS is precisely that they have managed to convince every browser vendor to support it. It has overcome or is strongly competing with Flash, ActiveX, native apps, PDF, and a lot else.

This magical CSS replacement would have to do that, even if CSS didn't exist.

Re:CSS: It was twenty years ago today by jl6 on Friday October 10, 2014 @12:29PM (#8438612)
Coming up with a competitor to CSS, HTML and JavaScript is a fruitless "if I were king" fantasy.

The way forward is to develop what we have to make it better, incrementally. Local maxima be damned, there is no alternative.

Re:CSS: It was twenty years ago today by cozuya on Friday October 10, 2014 @11:18AM (#8438152)
> only then FINALLY will it take another ten years for all browsers to support your new syntax so you can use it freely without worrying about incompatibility.

With IE10+ silently shipping evergreen by default its hopeful that this part of that problem will go away in the near future.

Re:CSS: It was twenty years ago today by Retric on Friday October 10, 2014 @10:28AM (#8437849)
HTML
Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @10:47AM (#8437963)
Do you remember coding rounded corners in HTML? Slicing images, putting a 3x3 table with rowspans and colspans? That was easier than `border-radius: 3px`?

And I have seen no solution for how we might code responsive layouts in pure HTML.

Re:CSS: It was twenty years ago today by Retric on Friday October 10, 2014 @11:38AM (#8438268)
Your making a lot of assumptions, but to be pedantic strait text + links is both pure HTML and a responsive layout. Sure CSS is useful, but IMO most of the pain from HTML / CSS / JavaScript is trying to recreate native application's pixel perfect layouts in a webpage. Also, I think you can embed all CSS functionality into strait HTML5 the advantage is CSS is concise not necessary. Granted, not something you want to create by hand, but if your code is generating HTML anyway it's not such a big deal. EX: <style>

In the end CSS was designed to allow you to swap CSS styles independent of the underlying HTML not add new functionality to HTML.

Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @12:31PM (#8438622)
> strait text + links is both pure HTML and a responsive layout

It's a responsive layout, but not one that somebody is willing to pay me to build. Those that people will pay me for are, in my experience, easiest to build with CSS.

Re:CSS: It was twenty years ago today by BigChiefSmokem on Friday October 10, 2014 @10:20AM (#8437804)
Your point is valid but please don't defend CSS, we deserve something better.
Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @10:28AM (#8437847)
I, for one, have given almost nothing back to the CSS. I don't read the papers, get involved with testing, implementation, or any of that. I don't even deserve table-based layouts.
Re:CSS: It was twenty years ago today by agumonkey on Friday October 10, 2014 @06:35AM (#8437054)
Interesting, since table based layout gave such ugly html sources. CSS might be incomplete, and too programmer oriented, but it has some value (it abstracts halfway).
Re:CSS: It was twenty years ago today by Swizec on Friday October 10, 2014 @07:54AM (#8437243)

    <div class="container">
       <div class="row">
         <div class="col-xs-4">
           What do you mean tables produced ugly html?
         </div>
         <div class="col-xs-3">
           Looks totes modern to me ...
         </div>
       </div>
    </div>
Re:CSS: It was twenty years ago today by gioele on Friday October 10, 2014 @09:30AM (#8437542)

  <body>
    <main>
      <p>It can be much better if you avoid abusing
         HTML classes for style.</p>
      <p>Classes are meant to describe the role of
         the tag, not its presentation.</p>
    </main>

    <aside>(use Sass instead)</aside>
  </body>
--

  /* Sass + Neat */

  body { @include outer-container; }
  main { @include span-columns(4); }
  aside { @include span-columns(3); }
Re:CSS: It was twenty years ago today by Touche on Friday October 10, 2014 @10:11AM (#8437738)
Unfortunately in the reason world you tend to design components that can be used anywhere in the page (and hopefully reused in different pages) so you don't get the freedom to work this way.
Re:CSS: It was twenty years ago today by blowski on Friday October 10, 2014 @10:45AM (#8437956)
Unfortunately true, although the Shadow DOM could help fix that.
Re:CSS: It was twenty years ago today by Swizec on Friday October 10, 2014 @09:38AM (#8437566)
I agree. We were producing the cleanest HTML back when "semantic web" was all the rage. Around 2009 I guess?
Re:CSS: It was twenty years ago today by lmm on Friday October 10, 2014 @11:36AM (#8438249)
Are you kidding? The semantic web was just a bunch of extra junk layers of indirection. Schematize everything, but nothing's actually using the schemata. Replace your <i> tags with <em> tags, because that's more semantic, and easier for a screenreader to interpret (this was a real argument made at the time). Write your actual page as an XSLT on top of what we'd now call your API - but XSLT is barely human-writable, never mind human-readable.
Re:CSS: It was twenty years ago today by porker on Friday October 10, 2014 @09:57AM (#8437663)
Before looks were everything and HTML reduced to a presentational markup?

I miss them days.

Re:CSS: It was twenty years ago today by agumonkey on Friday October 10, 2014 @07:58AM (#8437258)
Maybe I was conflating two things, deeply nested tables AND inline style (norm of that era).
Re:CSS: It was twenty years ago today by Swizec on Friday October 10, 2014 @08:20AM (#8437329)
Ah yes, we've at least gotten over the inline css ... although we seem to have gotten back into inline javascript with various ng-click="doSomething()" thingies.
Re:CSS: It was twenty years ago today by agumonkey on Friday October 10, 2014 @08:51AM (#8437404)
Sadly yes, and worse, people seem to enjoy this way. sigh
Re:CSS: It was twenty years ago today by DougBTX on Friday October 10, 2014 @09:44AM (#8437594)
A good talk about that is "Pete Hunt: React: Rethinking best practices -- JSConf EU 2013" http://www.youtube.com/watch?v=x7cQ3mrcKaY
Re:CSS: It was twenty years ago today by ufo on Friday October 10, 2014 @10:33AM (#8437872)
When you do everything from inside JS (as Pete advocates) then you have a real programming language to work with. Inline JS in the HTML is much less expressive.
Re:CSS: It was twenty years ago today by Swizec on Friday October 10, 2014 @09:35AM (#8437556)
As I wrote a few weeks ago[1], I hate this way but I can't argue with results. It's quicker and simpler to solve low-hanging fruit this way, which lets me spend cycles on application logic.

[1] http://swizec.com/blog/i-was-wrong-about-angularjs/swizec/66...

Re:CSS: It was twenty years ago today by xorcist on Friday October 10, 2014 @07:22AM (#8437185)
He is very much correct in this -- but do note that without the bad parts he dislikes we wouldn't have responsive design today.

It could have been implemented better, but the underlying thinking that users agents should try to programmatically position elements where possible is sound.