Hacker News new | ask | show | jobs
by internetter 864 days ago
Do you want your div centered vertically? horizontally? both? Relative to what? the window? the container? These are just some of the common questions that are asked every time you need to centre something. A simple attribute cannot work.
2 comments

> Relative to what? the window? the container?

I don't think I ever wanted things centered relative to anything other than the direct parent, no matter what that is. I am sure some cases need it differently, but I don't see why those should prevent intuitive defaults.

> A simple attribute cannot work

Can it not work at all or just if one insists on covering 100% of cases on the internet with a single comprehensive option? I'm not an expert in this so I'm not sure, but I've seen a lot of software center items automatically and it worked quite well because they didn't assume by default that I might push the boundaries of design to new heights at any moment.

It worked exactly that way with tables, attributes align and valign:

https://www.geeksforgeeks.org/html-td-tag/

Tables only ever "worked" when compared to the poor implementation and browser support of the alternatives of its time.

In today's web landscape using tables to center categorically fails to work in many scenarios that will work with flexbox.

They worked great and still do for the vast majority of use cases.

The fact it took over two decades to surpass is not a compliment at all. Considering "internet time" (first identified in the 90s), it's a disgrace.