3 ms·
The history of CSS is one where Microsoft earned an awful lot of bad will and what an epic fail the W3C has been in this regard. Microsoft of course deviated f
by cletus 13y ago
The history of CSS is one where Microsoft earned an awful lot of bad will and what an epic fail the W3C has been in this regard.
Microsoft of course deviated from the nascent "standard" such that we've been burdened for years with "if IE ..." blocks to the point that the latest version of IE pretends not to be IE.
You reap what you sow.
But every time I come across the issue of "how to vertically center in CSS", an issue that has existed for years, I get angry. I get angry because the old way (vertical alignment on table cells) just works. As much as the CSS purists (some might call them "anti-table zealots"), it's hard to argue with something that works all the way back to IE4 and probably beyond (well valign="middle" probably does, CSS vertical-align: middle is probably IE5/6).
But beyond this there are so many things in HTML/CSS that should be simple but are hard. This is just one of them.
Consider spacing between table cells. There's (still) actually no way to do this... if you want no spacing between the leftmost and rightmost cells and the edge of the table, which I find is a pretty good use case. People end up doing things like:
td { margin-right: 0.3em; }
td:last { margin-right: 0; }
Any such solutions had varying backwards compatibility issues, a problem we're now largely getting behind us, but still...
Why can't I specify (separately if need be) the vertical and horizontal spacing between cells separately to the edge of the table (which should really be a property of the table rather than the cells IMHO).
The problem here is that the CSS WG seems to have started with a model and then just run with it without running it through very common use cases.
Looking at the article, it looks fine. One thing I'll say is it starts off with the "margin: 0 auto" trick, which everyone who does anything with CSS needs to know. Why is centering that hard? Why can't I just say "put this in the center"? Why can't I then use margins to offset from center or something?
Also FWIW, the margin: 0 auto thing didn't work in older versions of IE if you didn't specify a DOCTYPE and force "standards compatibility mode" (rather than the euphemistic "backwards compatibility mode".