Yelotofu

Yelotofu ~ “In building standards compliant sites we are creating a better Web for the future.”

Archive for May, 2007

Styling table columns

The Colgroup element has existed for quite some time now. Its purpose is column grouping. It's also in the class of under used elements. With Colgroup each column can be styled individually in a way similar to how we style table rows. Unfortunately most of todays browsers do not fully support the styling capabilities of Colgroup. FF2 only allows you to style the width and background-color properties whereas IE7 allows anything. Admittedly IE7 is the winner here. You can pretty much give a Colgroup element any style and IE7 will happily apply it to the table. Take a look at this basic Colgroup example and compare the difference between FF2 and IE7.

It's quite dis-heartening news. However, there is a workaround. And it's in the form of valid CSS. The adjacent sibling selector (+) could be used to select the nth cell of a table row. 99% of the time we'd be dealing with fixed column data. Therefore we could programatically retreive the correct column to style on a per row basis. Take the following example. To select the second column we'd do:

td:first-child+td {
  put your column style here...
}

Now to select the fifth column just carry on with the plus':

td:first-child+td+td+td+td {
  put your column style here...
}

It's not elegant, I know, but the beauty of this approach is that both FF2 and IE7 supports both + and first-child selectors. And as far as I'm aware the latest MOS browsers do too.

Note: IE6 does not understand any of the things I've mentioned here so please do take this article with a pinch of salt until IE6 is completely phased out.

Hong Kong: Queue Nation

It is amazing how Hong Kong being such a small speck on the face of the Earth with such a high density of people can still operate smoothly and coherently. The fact that Hong Kong is as it is today has much to do with the way her people were brought up. Just go out for a day and keep count of the queues you come across, there is one in nearly every street corner. Hong Kongers queue for everything! Buses, Trains, Food, Toilet, Taxis and even free product tester packs worth pennies. Where there is a person standing and waiting for something someone else will inevitably queue behind and immediately a queue is formed. Even when there are no barriers or uniformed personnel to guide queues, the instinct of a Hong Konger will form a natural queue. It's a strange but amazing phenomenon.

It all boils down to the deeply nested teachings of Confucius in the myriads of Chinese textbooks that Hong Kongers study since primary years. Confucius was a great philosopher and leading thinker of his time. Confucius' Golden rule, taken from the Wikipedia page on Confucius, states:

"What one does not wish for oneself, one ought not to do to anyone else; what one recognises as desirable for oneself, one ought to be willing to grant to others."

Though the second part of the Golden rule is less practiced the first part is very much used. Mainly in the form of not doing anything to others, i.e. reduce human interaction and stand a better chance of not doing wrong to your neighbour. For the purpose of queues this idea translates to:

Do not interfer with the person infront of you but silently stand behind them minding your own business. Doesn't sound nice does it? but that's the basis of forming a perfect queue. ;)

I know this post is completely off topic and I probably could have come up with something better to say since I haven't said much lately. I just had to get it off my back as it's a special kind of Hong Kong small city phenomenon.

Lastly, I mentioned Confucius a few times in this post, though I must profess I'm not an expert in Confucianism so probably won't know anymore than what I've already said. :)