Hacker News new | ask | show | jobs
by layer8 491 days ago
What do you do when there is no solution to the set of constraints? What do you do when there are multiple (usually infinitely many) solutions to the set of constraints? More importantly, how do you specify the behavior for those cases such that all browsers behave identically? I’m not saying that CSS is better (it’s not), but it’s a bit more involved than “just run a CSP solver”, and you can still get surprising behavior depending on window size, font size, content size and so on.
1 comments

What do you do when there is no solution to the set of constraints?

You break the one with the lowest priority. Then another one, until it solves. You may create groups and break whole groups (to e.g. simulate “media” “queries”).

What do you do when there are multiple (usually infinitely many) solutions to the set of constraints?

Add constraints if they are missing, or, in case you wanted it to be underconstrained, allow the mentioned distribution algos to find extremums and allocate “space” accordingly. A naively underconstrained system will solve into just something, whatever. Just like html does something when you write zero css.

More importantly, how do you specify the behavior for those cases such that all browsers behave identically?

In text? I don’t get the question. If a behavior is programmable, it is specifiable. In fact, this specification will take 100x less sentences than the current mess.

it’s a bit more involved than “just run a CSP solver”, and you can still get surprising behavior depending on window size, font size, content size and so on.

Do you have any examples? Feels like simply not true.