News for hackers. Stuff that matters.
Re:How to center a div in CSS by internetter on Tuesday February 13, 2024 @03:59PM (#39362752)
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.
Re:How to center a div in CSS by mixmastamyk on Tuesday February 13, 2024 @04:40PM (#39363209)
It worked exactly that way with tables, attributes align and valign:

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

Re:How to center a div in CSS by JacobThreeThree on Tuesday February 13, 2024 @05:25PM (#39363674)
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.

Re:How to center a div in CSS by mixmastamyk on Tuesday February 13, 2024 @05:54PM (#39363991)
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.

Re:How to center a div in CSS by alpaca128 on Tuesday February 13, 2024 @05:26PM (#39363699)
> 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.