Why noone uses CSS for layout

28 March 2007
Every once in a while I decide that my website need an overhaul, or at the very least a correction of old bugs. Most recently it was because I had a large backlog of image sets to add to the pictures section, and the index was getting rather long. One thing I decided would be nice is if the tiling of the images was to take account of window width rather than always being fixed at two across. I also decided to use CSS rather than tables. Big mistake.

If it is just images, then only a few lines of CSS are needed to adjust things like padding. The problem is that I occasionally tag images with caption, and this is where the nightmare starts. Sticking together images and captions requires some fancy nesting of (for instance) DIV elements, and even then some assumptions (e.g. text size) that I would rather do without have to be made. Eventually something reasonably functional gets made.

Then you try it in that monstrosity known as MSIE. MSIE6's support of CSS is seriously broken (MSIE7 has to be considered beta until MSIE6 is forcibly retired). Do a websearch for some of the more fancy CSS tricks and you start to see a LOT of browser-dependent hacks. Before long you realise that if you want a site that allows for resizing of either text and/or browser windows, CSS is useless. In the end I gave up and used some JavaScript to restructure the layout table on window resizing. MSIE still doesn.t handle it correctly, but at least it simply fails to run the JavaScript at all rather than producing a complete mess.