Hacker News new | ask | show | jobs
by hombre_fatal 857 days ago
`<div centered>` is the same thing as `<div read-my-mind>` since there are so many variations of what you might want. And once you generalize the solution around those variations, you have something like flexbox.

For example, what does `<div centered>` do when there are two children? And what do you do when you want the opposite behavior?

2 comments

> For example, what does `<div centered>` do when there are two children?

Force me to use the advanced option or to wrap the two children in a centered container? I am certain this wouldn't cover many, many edge cases, but they are called edge cases for a reason.

Edit: People can complain about tables etc being the wrong approach all they like, in the end those examples are only proof that the proper way could be at least as simple for the average case.

It takes the sum of two children’s intrinsic sizes with a margin between them and centers the bounding rectangle as if it was a single object. Flexbox does the same, and I didn’t even think of it while writing the previous sentence. But somehow you didn’t have the same read-my-mind complaint about flexbox.
Because flexbox picks a default when you give it no configuration but it lets you configure it, so it doesn't need to read my mind and it can be wrong every time.

Now show me how you change spacing/centering behavior with the proposed <div centered> and you'll finish out the point of my previous comment.

Contrast the need to use flexbox with the ability to just specify bold or italic style, or for that matter use <b> or <i> tags. You basically get what you want every time. Nobody has to argue about whether the italicization is the right slope, and while you can select a particular font weight if you want to, bold is bold and is fine for basically everybody.

Hell, I would argue that centered table contents gave people what they wanted most of the time, and if it didn't you could fix it by adding more tables. Tables composed quite nicely and gave you something if you just laid down a table and some TDs.

Flexbox doesn't scale down the way tables do. I have to have both the container and elements inside that container and think about the ramifications of all of that. It's minimum level of complexity is a higher floor than most of the HTML specification.

That's not to say it's the wrong solution for the problem; I think a case can be made that the problem itself is irreducibly complicated. But that's why I say it feels like using an elephant gun relative to much of the rest of the spec; I have a "read my mind" option for bold and italic.