The Lounge is rated Safe For Work. If you're about to post something inappropriate for a shared office environment, then don't post it. No ads, no abuse, and no programming questions. Trolling, (political, climate, religious or whatever) will result in your account being removed.
simple math formulas into the CSS, that refer to the sizes of other elements.
The good news - since it requires some basic math skills we'd see a drop in the number of (so called) designers.
The bad news - it's still potentially overly complicated and allows for possible feedback loops.
My guess: if it worked as you wished you'd be making the same complaint.
I'm not talking about clever ways to generate complex CSS, I'm talking about expressing relationships between page elements that is not possible at all with current CSS.
For example: "The height of element B is 1/10th of what ever the page height is at the moment. The width of element A should be equal to the height of element B, but only if B's height is less than 100px, in other case it should be half of the height of element B.".
Here is how simple it could look in theory: B.height = PAGE.height / 10; A.width = B.height < 100px? B.height : B.height / 2;
The reason stuff like that isn't possible is because you will get endless recursion.
Let's say you have:
The height of B is determined by the content of A, but if you are changing the width of A based on the height of B then the height of A will also change, which in turn forces the height of B to change, which would then require the width of A to change, which will once again change the height of B, and the loop continues until you get a StackOverflow exception.
So perhaps you say: "Well, don't allow rules like that", but then you end up with even more of a headache trying to make sure your rules don't conflict with other rules.
Put it this way, if it was possible to make it work well then it would for sure already exist.
As the saying goes: if you have a good idea, it either already exists or it really isn't that good an idea.
What you describe already happens in the layout engine of modern browsers. The rules that I outlined earlier already happen, but is invisible to us. There are hundreds of such rules that must be evaluated to produce the final layout, and some are in direct conflict with each other, so the engine is designed to make a compromise. These compromise heuristics is what avoids endless recursion.
So imagine that tomorrow the Google Chrome team launches a new module called JSCSS, were they have moved out all those heuristics from inside the layout engine and written them in JS. From now on you point to a JSCSS file at the beginning of a HTML page, which defines all the CSS rules you intend to use. CSS still works exactly like before. But the HUGE difference is, now you can see how a flexbox actually figures out layout, AND you can extend CSS with your own definitions for things you think is better than the standard. AND you can omit CSS altogether, and write your layout directly in JSCSS of you want.
This would be a huge relief for everyone, because browser makers only have to make sure the core layout engine works correctly, and every CSS definition is in external JS, exactly the same for every browser. And any developer can extend CSS with his own definitions.
That feature doesn't exist, because IMO it's something that we shouldn't do to begin with. Websites are displayed on various screen sizes, contrary to Windows App which almost definitely shown on a monitor.
If you fixed the size of element b as 1/10 of total web page's height, it will be nightmare/unreadable on some screen sizes.
If it's screen size, there already "vh" and "vw" as unit size.
Whilst I don't disagree with you re:CSS, in that example you've given it could be easily achieved using JS / jQuery.
It's simply a case of picking the right language for the job.
Of course as others have picked up on, doing that might cause all sorts of strange behavior once you start looking at the various sizes of screens your page may show up on, from 1 inch watches to 100 inch projectors. You just can not be sure of the scale your user will be using.
Like this[^], you mean? The calc() functions in CSS are useful, potentially (though I've not used them myself) but they don't directly include the ability to refer to other elements. However you can refer to CSS custom variables which may give you the flexibility you want. But hey, all this is just adding more bloat, and making it harder to learn (and test for cross-browser compliance). The trouble is, the features you want are not the same as the features someone else wants - and pleasing everyone is what leads to bloat in the first place.
It's a language by committee. And a committee made up of teams that are actively competing with each other. Read this discussion on CSS4[^]. They actually, deliberately, don't want to increment the CSS version anymore. That's like macOS stopping at version 10 (...but instead is 10.1, 10.2 etc), and Windows 10 stopping at 10. Or 10 20H1, 20H2...)
I think the hardest part of CSS is the "C" - the cascading, which relies on Specificity. It's super logical and very well defined. And an utter nightmare as soon as you step off the beaten track. Switch elements around, decide you need some special formatting, try and generalise it, and boom!
Still - it does at least attempt to encourage a separation of layout and style. Except the CSS defines the layout
Yea I wish CSS was only about style, and layout was handled in a different way. I think it is possible to keep the core layout engine of the current browsers, and create a kind of scripting language they can run, so the developer can interact with the layout procedure. These ideas have been proposed before, so I can't understand why we still have CSS today. I was cursing HTML layout 15 years ago, and couldn't imagine we would still be doing things the same way today.
Some developments in this space have been amazing, but HTML/CSS/JS has really been a disappointment. There is still not a practical way to write C# and run it in the browser, just promises of WASM and compilers that never hit mainstream.