Google Analytics

Monday, September 26, 2005

How to waste time in one easy step

I came across a problem yesterday while modifying a Joomla! template. The template I was making was kind of a hybrid of two different ones. One of them started like so:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


That is, the XML declaration followed by the doctype. The other template began:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<?xml version="1.0" encoding="iso-8859-1"?>


So the doctype and XML declaration were switched. Each template then proceeded to make heavy use of CSS and a mix of <div>'s and <table>'s in a complex layout.

Once I had finished the new hybrid template I then encountered every web developers worst (yet most common) nightmare. The template looked fine in Firefox, Opera and other sane browsers but not in ye olde Internet Explorer. The anomaly it caused is hard to describe. It was a sort of spilling in the rightmost <div> column.

To cut a long story short, I spent hours trying to fix the template and only after I had gone through every piece of the HTML body and CSS did I realised that all that was needed was to switch the doctype and XML declaration so that the XML declaration came first! I had used the template where it came second by chance (where it had no adverse effect).

Back when I started web design in the mid->late 90s Internet Explorer 4 had a much more complete CSS implementation than Netscape 4, and was by far a much more enjoyable browser to make sites for. These days the exact opposite is true, and IE is an absolute headache. Any IE user should do themselves a favour and download Mozilla Firefox right away!

No comments: