pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
[personal profile] pne

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 margin-left and margin-right to 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.stylesheets and downloaded the headers for all the articles the news server had in that group (going back to March, as it turned out).

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):

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.

Date: Tuesday, 5 August 2003 07:35 (UTC)
From: [identity profile] nik-w.livejournal.com
It took me a while to work out how to do that when I wanted to do it a few months ago, but I eventually found the answer on google:D

Profile

pne: A picture of a plush toy, halfway between a duck and a platypus, with a green body and a yellow bill and feet. (Default)
Philip Newton

June 2015

S M T W T F S
 12 3456
78910111213
14151617181920
2122232425 2627
282930    

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated Friday, 2 January 2026 19:09
Powered by Dreamwidth Studios