I had written a CGI script that would output a bunch of tables with data from a database, and I wanted those tables to be centred on the screen (and on a printout), to match the originals from which I had copied the data.
I wanted to do this with CSS, so I had a look around the specification and found that if you set both
auto, their computed values are the same. This would mean that the two margins on either side of the table would be equal and so the table should be centred. I tested this in my two most frequently-used browsers, Opera 6.04 and MozillaFirebird 0.6, and it worked fine.
A bit later, I sent someone the URL to the CGI script. Because I assumed he would be using MSIE, I just gave it a quick check to see whether it would look all right. Oops—the tables are now left-justified. WTF? I simply told him it wouldn't work in MSIE but resolved to ask on Usenet when I got the chance.
Today, I subscribed to comp.infosystems.www.authoring.styleshee
I created a minimal test case (since I remember people such as Alan Flavell, whom I respect, telling people off in comp.infosystems.www.authoring.html for not putting up a test page on the Web but asking in a newsgroup that contains "www").
Being a good Usenet user, the first thing I searched for in the list of subjects was "FAQ", but I didn't find anything. Next, I searched for "cent" in order to find all subjects matching "center" or "centre" (and some others, such as "recently"). This brought up quite a few likely ones (some very specific, asking about centring(sp?) tables, some a bit less specific to my problem such as requests for centring images), so I tagged those for download and started reading.
I found people who had very similar problems and who were answered by links to HTML documents. The most useful such links were (in roughly decreasing order):
- http://theodorakis.net/blockcenter.html and http://theodorakis.net/tablecentertest.html
The first page also provided some CSS code which centred the table on all tested browsers while not centring the contents of the table cells. Made a couple of changes to the stylesheet my CGI script was writing out and—presto, it works!
And this is why I love Usenet. Sure, I could probably have found something on a Google search somehow, but Usenet comes nicely pre-categorised and, since it tends to be frequented more by geeks, can have a higher signal-to-noise ratio than the Web.