News for hackers. Stuff that matters.
Re:Incomplete List of Mistakes in the Design of CSS by devwastaken on Wednesday October 24, 2018 @10:29PM (#18298173)
I don't think things like syntax and schemes are the real bad parts. The real bad part is that CSS is in no way designed to be interacted with by anything but CSS.

Just yesterday I was making a music player position bar, and using CSS transitions to have it smoothely update itself. Set the duration of the transition and it goes on.

But what about when the transition takes effect? JS doesn't know when a style is actually updated and can then have a new property overwriting it to make the transition happen. If you do properties too quickly the transition won't happen. Such as if a user clicks on the bar to change the position, I have to hack in a 100ms setTimeout to set the new transition duration after stopping the transition with transition:none;

Why can't I control a transitions location? Chrome's animation viewer can go back and forth in time easily.

Why isn't interactivity seperate from CSS? CSS elements cannot effect those outside of its scope. You require JS for just dumb simple things that should be natively supportable. For instance you can make CSS do things based upon URL hash names like #somename, but you can't set them in CSS. You can't change attributes on elements, or classes or anything like that.

I think we've gotten to the point where JS is the 'programming language' of a webpage that has intentions far beyond rendering and interactivity. Perhaps we need a newer kind of CSS that's made for dynamic interactions. That way great UI's can be built in a safer css-like environment.

Re:Incomplete List of Mistakes in the Design of CSS by _hardwaregeek on Wednesday October 24, 2018 @10:48PM (#18298260)
Yep yep. CSS in JS removes some of the pain points but still, fundamentally, CSS cannot communicate with JS in a universal, elegant way. Honestly, CSS in general is awful. How did we only just get decent centering with flexbox? How is flexbox still inconsistent across browsers? (Try setting a child of a flexbox container to 100% height.) The days of needing separate constructs because of bandwidth are over. We need something to unify CSS and HTML and JS into a UI builder that doesn't make you want to tear your hair out when you have to center a div over another div and give it an animation.
Re:Incomplete List of Mistakes in the Design of CSS by combatentropy on Wednesday October 24, 2018 @11:30PM (#18298380)
> Try setting a child of a flexbox container to 100% height.

Isn't this the default?

   align-items: stretch
--- https://css-tricks.com/snippets/css/a-guide-to-flexbox/

> The days of needing separate constructs because of bandwidth are over

That wasn't the reason for stylesheets. It was for ease of changes. For example, to change the color of the headings on all of your HTML pages, you would change just the stylesheet. This was when each web page was a static HTML file. Few websites used programming languages to render pages. So the benefit today is less.

But I guess if you don't care about that nor bandwidth then you can use inline style attributes.

Re:Incomplete List of Mistakes in the Design of CSS by _hardwaregeek on Wednesday October 24, 2018 @11:36PM (#18298400)
https://stackoverflow.com/questions/33636796/chrome-safari-n...

I'm referring to this. Got bitten by it recently.

> That wasn't the reason for stylesheets. It was for ease of changes. For example, to change the color of the headings on all of your HTML pages, you would change just the stylesheet. This was when each web page was a static HTML file. Few websites used programming languages to render pages. So the benefit today is less.

Interesting, I didn't know that. Still, CSS doesn't make a whole lot of sense to me. Here's a bunch of global state, some of which is hidden in gigantic minified files, now edit it!

Re:Incomplete List of Mistakes in the Design of CSS by adrianN on Thursday October 25, 2018 @05:46AM (#18299662)
Back when CSS was useful for changing the color of all your headlines without changing all your HTML, it wasn't delivered in giant minified files, it was a couple dozen lines written by hand.
Re:Incomplete List of Mistakes in the Design of CSS by irrational on Thursday October 25, 2018 @12:31AM (#18298551)
>Here's a bunch of global state, some of which is hidden in gigantic minified files, now edit it!

Well, there's your problem. I'd recommend reading about things like atomic css, BEM, OMACSS, etc.

Re:Incomplete List of Mistakes in the Design of CSS by _hardwaregeek on Thursday October 25, 2018 @12:37AM (#18298564)
That's why I use CSS in JS :D. But we're just putting abstractions/stopgaps over a fundamentally flawed design. Not to mention, since everybody uses a different standard for isolation, CSS in JS is not compatible with BEM is not compatible with SASS, etc.
Re:Incomplete List of Mistakes in the Design of CSS by ZenPsycho on Thursday October 25, 2018 @12:51AM (#18298614)
CSS was originally designed with the idea that you would have one css file for your whole site, and it would be maybe 300 lines max.

We've obviously gone well off the rails. Selector specificity was supposed to be the scoping mechanism. And it works great in the original envisaged usescase: a single person making a single website. it just doesn't scale to large teams, and ancient software projects, with complicated layouts.

Re:Incomplete List of Mistakes in the Design of CSS by laumars on Thursday October 25, 2018 @01:42AM (#18298750)
It never worked well in the original envisaged usecase. CSS 1 didn’t work properly with tables which meant I used to have to inline style attributes for tables as well as set a CAS file. It’s always been garbage for centering things, in the early days that meant using the <center> tag. Then you have all the different browser extensions (o-, mo-, etc) the inconsistent preferences for font-face, etc.

CSS was a great idea but it’s always been a garbage execution of that with no single browser following the spec correctly for years then each browser going off and adding their own crap when the spec ended up languishing (thank you W3C for sleeping while the web leapfrogged into the future).

I’m not a fan of HTML (I think that was good for it’s time but could use deprecation) nor JavaScript (but I’ll concede this is personal preference - however wouldn’t it be nice to have browsers run byte code so you could have a choice of languages rather than having compile everything down to JavaScript?) but CSS is easily the worst of a bad bunch in my personal opinion.

Frankly I don’t even get why people are defending it. Any programming tool that reduces the developer down to hours of trial and error just to do basic things is clearly a misstep. Sure, expert front end developers with years of experience and using bloated frameworks cope fine; but why have we allowed ourselves to get into this kind of mess in the first place?

I would honestly welcome a ground up complete reimplementation of the web if browser vendors all decided to work together on one.

Re:Incomplete List of Mistakes in the Design of CSS by scns on Thursday October 25, 2018 @04:53AM (#18299468)
Learn CSS Layout the pedantic way at:

http://book.mixu.net/css/

can help with the trial and error bit. It impossible to get an intuitive feel for nearly 400 keywords IMHO.

Re:Incomplete List of Mistakes in the Design of CSS by laumars on Thursday October 25, 2018 @05:40AM (#18299634)
That's great reference (thank you for the link) but one of the great - if not the single greatest - accomplishments of the web was that it allowed anyone with a text editor and access to the internet to publish content with ease. I get that commercialisation of any platform will lead to specialities in that field; however the tools shouldn't make it objectively harder for new comers to contribute. Let alone discriminate against hobbyists who might not want to spend several hours of their life learning CSS (never-mind HTML, perhaps Javascript, how cookies work and any regional legislations, OWASP should they dare to have any user submission forms, etc).

Talking personally, I published my first website in 1994 when there wasn't different layout modes. Now it is suggested that I read a multi-chapter book just to learn what's changed in CSS so I can publish the same content I had before but in a "web 3.0" (for want a better description) format.

I appreciate my comments are very ranty / preachy and do value your comment as I hadn't seen that link before; so my comments are not directed at you in any negative way at all! What I'm essentially just trying to say is web development has become very frustrating for anyone outside of the webdev community. Heck, I find it frustrating and I used to specialise in hardening web servers so have worked quite close to that community.

Re:Incomplete List of Mistakes in the Design of CSS by quakenul on Thursday October 25, 2018 @07:59AM (#18300219)
It is as simple as it ever was to do what could be done 15 years ago with a simple text editor and access to the internet. Any adjoining aspect has gotten easier and cheaper by a magnitude.

It's just that what people want has gotten a lot harder to build.

Re:Incomplete List of Mistakes in the Design of CSS by laumars on Thursday October 25, 2018 @08:36AM (#18300386)
The removal of the <center> tag in place of CSS black magic is definitely not "easier" than it was 15 years ago. However I suspect this is going to be one of those debates that we have to agree to disagree on.

I should add that I don't disagree with the deprecation of <center> from a language purists perspective. However it was still a step backwards in terms of ease of development when centring stuff in CSS is so clunky in comparison.

Re:Incomplete List of Mistakes in the Design of CSS by ZenPsycho on Thursday October 25, 2018 @07:49PM (#18305626)
though i resisted for a long time, bootstrap brings back some of the old ways. <div class=“d-flex justify-content-center”>centered</div>
Re:Incomplete List of Mistakes in the Design of CSS by dylan604 on Thursday October 25, 2018 @03:08AM (#18299051)
>I would honestly welcome a ground up complete reimplementation of the web if browser vendors all decided to work together on one.

Was that the sound of a pig flying by, or the sound of hell freezing over? Any time specs can be interpreted, there will always be these differences in browsers. Maybe we could not call them specs, and just call them suggestions?

Re:Incomplete List of Mistakes in the Design of CSS by laumars on Thursday October 25, 2018 @04:13AM (#18299320)
Ostensibly I do agree with you however that is the reason I phrased it "browser vendors working together" rather than "a new spec being written".

However, as you said, the chances of that happening are remote. Even putting personal agendas aside (eg Google wanting to control content via AMP), the web in it's current form is "good enough" that there's no real drive to reinvent the wheel for something with such deep market penetration already.

Re:Incomplete List of Mistakes in the Design of CSS by thaumasiotes on Thursday October 25, 2018 @03:33AM (#18299148)
> wouldn’t it be nice to have browsers run byte code so you could have a choice of languages rather than having compile everything down to JavaScript?

How are those two situations different? You're compiling one language to another language. Does it matter if one of them is called "bytecode"?

Re:Incomplete List of Mistakes in the Design of CSS by laumars on Thursday October 25, 2018 @04:08AM (#18299298)
The Javascript equivalent of byte code would be web assembly and that is still a long way from being ready for primetime.
Re:Incomplete List of Mistakes in the Design of CSS by thaumasiotes on Thursday October 25, 2018 @12:19PM (#18302073)
The question is, why isn't "the javascript equivalent of bytecode" just javascript? Why do you think there's a difference between "javascript" and "bytecode"?
Re:Incomplete List of Mistakes in the Design of CSS by gsnedders on Friday October 26, 2018 @05:34AM (#18307870)
The spec has changed on multiple occasions around whether flex items are definite sized or not, which is part of what of what's caused the lack of interop here.

The problem here is specifically having a percentage sized child of a flex item (and Chrome and Safari don't match the current spec, as the flex item is indefinite sized in too many cases; Firefox doesn't either, as the flex item is definite sized in too many cases!); to make the flex item definite sized everywhere you can typically just add height: 0.

Re:Incomplete List of Mistakes in the Design of CSS by ArchTypical on Thursday October 25, 2018 @12:21PM (#18302103)
> The days of needing separate constructs because of bandwidth are over

> It was for ease of changes.

Wat? Not solely. CSS had many goals, the primary reason was a separate styling language that could be universally interpreted and expanded, without involving HTML (or any other standard like ECMA). HTML versions were already bogged down in semantic squabbles.

Re:Incomplete List of Mistakes in the Design of CSS by VonGuard on Wednesday October 24, 2018 @11:26PM (#18298368)
The thing i hate about CSS is how unstructured it can be. You just sorta list whatever you want and it's suddenly a style sheet. No headers, no footers, no must includes.... DO I use quotes around this value? Do I not? Does white space matter? It's the most intimidating language I've ever used just because it feels so open and uncontrolled and nonsensical... I always thought CSS was some leftover abomination from the days of Netscape.
Re:Incomplete List of Mistakes in the Design of CSS by devwastaken on Wednesday October 24, 2018 @11:31PM (#18298384)
LESS is more how CSS should look like for styling. It's amazing we don't have embedding of rules yet.

parent {

   child {

    }
}

is just so much more development friendly than

parent {

}

parent child {

}

Re:Incomplete List of Mistakes in the Design of CSS by gsnedders on Thursday October 25, 2018 @10:55AM (#18301345)
The CSS WG earlier this year resolved to take on a spec defining this, and there's implementer interest, so it's highly likely to happen.

(This is https://github.com/w3c/csswg-drafts/issues/2701 .)

Re:Incomplete List of Mistakes in the Design of CSS by bsheir74 on Wednesday October 24, 2018 @11:49PM (#18298443)
Agreed, and hoping that scss or less influences future versions of css!
Re:Incomplete List of Mistakes in the Design of CSS by mjevans on Thursday October 25, 2018 @04:48AM (#18299446)
I believe the why is that as soon as you have any invalid syntax everything else is ignored. I forget the level of scope, I think it's until the next complete rule?
Re:Incomplete List of Mistakes in the Design of CSS by scns on Thursday October 25, 2018 @04:58AM (#18299489)
with PostCSS and the postcss-nested you can nest loads of stuff like mediaqueries, which makes it bearable IMHO.
Re:Incomplete List of Mistakes in the Design of CSS by _hardwaregeek on Wednesday October 24, 2018 @11:36PM (#18298404)
Plus the error handling is abysmal.
Re:Incomplete List of Mistakes in the Design of CSS by pcmaffey on Wednesday October 24, 2018 @11:48PM (#18298434)
Yes, this is all right on. And it's being solved in modern component libraries that combine JS, HTML, and CSS into modular building blocks for UI's.

The key difference IMO in how to think about CSS nowadays is to move away from the paradigm of CSS as a global system, and instead, use it locally scoped to components. I like to think of CSS classes as a kind of local state. Most often, in layout components and whatnot, its static. Otherwise, in more dynamic situations, rather than messing with css properties directly (or passing vars via css-in-js), the component's js manages the "state" of the classes being applied by adding/removing.

When you start to think in this composable component framework, styles are just another component. And js is used to manage changes in state, which it is much more apt to do.

Re:Incomplete List of Mistakes in the Design of CSS by dao- on Thursday October 25, 2018 @03:57AM (#18299254)
Off the top of my head, there are transition events, requestAnimationFrame, and most importantly the Web Animations API. So what you're saying seems to be false.
Re:Incomplete List of Mistakes in the Design of CSS by iaml on Thursday October 25, 2018 @10:53AM (#18301327)
>JS doesn't know when a style is actually updated and can then have a new property overwriting it to make the transition happen.

It's not easy, but it's possible. All animated/transioned elements emit lifecycle events like animationstart/transitionstart so you can use those to orchestrate complex animations. This is AFAIK how ng-animate works internally.

Re:Incomplete List of Mistakes in the Design of CSS by XCabbage on Thursday October 25, 2018 @08:37AM (#18300390)
> But what about when the transition takes effect? JS doesn't know when a style is actually updated and can then have a new property overwriting it to make the transition happen. If you do properties too quickly the transition won't happen. Such as if a user clicks on the bar to change the position, I have to hack in a 100ms setTimeout to set the new transition duration after stopping the transition with transition:none;

There's a slightly more reliable and less ugly hack than using a timeout, which I _think_ is applicable to the scenario you're describing: instead, force a reflow by reading the element's .offsetHeight. I wrote about this on Stack Overflow years ago: https://stackoverflow.com/a/16575811/1709587

Not disagreeing with the overall thesis of this post, just pointing out a slightly less annoying way to work around the problems from application-developer-land.

Re:Incomplete List of Mistakes in the Design of CSS by krapp on Thursday October 25, 2018 @03:21PM (#18303758)
>The real bad part is that CSS is in no way designed to be interacted with by anything but CSS.

Am I the only person who thinks this is a feature, and that the "bad part" is CSS supporting animations and transitions?

I mean - HTML for markup, CSS for layout and colors, JS for logic and animation. There was a very clear and well defined separation of concerns to the web, why did we have to go and ruin it by making CSS almost Turing complete then having everyone generate CSS and HTML with javascript?

Re:Incomplete List of Mistakes in the Design of CSS by archergod on Thursday October 25, 2018 @08:17AM (#18300303)
even HTML cannot communicate with JS, you are talking about collective Web page behaviour running in JS/CSS/HTML/Browser. CSS is standalone, it doesn't have logical brain. It don't think. That is part of JS. I don't agree with your idea, if we add logic to all HTML and CSS then it is like batman doing killing.