Cross-browser consistency

Once upon a time there was a business that wanted a very simple website. So I built one as a small project. It had a few pictures and some text. I looked at it in IE7 and it looked OK. It was a first step into the web world for the business. The client was happy.

A year passed. The website started looking a bit tired. It needed some more pictures. So I rebuilt it, added more pages and a lot more pictures. I looked at it in IE7. It looked OK. I looked at it in Firefox as well. It looked OK. It didn’t look quite the same as it did in IE7. I found that if I used tables in the design, some (but not all) of the differences between IE7 and Firefox 3 went away. (Don’t start shouting until you’ve read the rest of this page….) I decided I could live with the differences. I didn’t understand why Firefox was getting it wrong though. The new website went live about 2 months ago. The client was happy. So were his customers.

For other purposes, for another website, I’d been learning a bit about “Cascading Style Sheets” – css to the initiated.

I happened to show the website to someone I was working with. Having previously been quite proud of it, I was a bit embarrassed – the site navigation looked a bit naff. So I made the navigation look like buttons. It was quite easy to do this using the css I’d learnt. So I extracted all the style into a separate css file. The page looked quite a bit better with the buttons. The client was happy. It still didn’t look quite the same in IE7 as it did in Firefox 3. I decided I couldn’t live with this any longer. I spent hours trying to understand this. As a result of this I learnt a lot about css. Every time I looked at the html or css I spotted something that could be done better, so I changed it. This became a fascinating journey into the world of modern web applications, or as my wife called it, an obsession. Where I could get it to work, I got rid of the tables I’d used. I got rid of some of the differences between IE7 and Firefox. I started to realise it was IE7 that was doing the unexpected things, not Firefox. I started viewing what I built in Firefox first not IE7 first.

I made the mistake of posting a question on a discussion board. In line with all website discussion boards everywhere, I didn’t quite get the answer to the question I asked, but I did get some comments about how the website was built, using lots of absolute positioning. I rebuilt the website using some suggested code off the discussion board to use floats and margins instead. It still looked pretty much the same to the untrained eye…..(not someone comparing using a pixel ruler).

Getting curious, I had a look at the website in Chrome as well. It looked the same as in Firefox. Hurrah. Then I looked in Opera. Boo.  All the text was cut off on the right (EDIT: which I now realise was this problem, and nothing to do with margins at all). I took all the floats and margins back out. It looked OK in Opera then. I went to bed…..

In the morning I started again. I got rid of all the absolute positioning again. I did it in a slightly different way and it seemed a lot easier. I got rid of an extra line showing up in IE that was at the top of every page. The Home page looked identical in IE7, Firefox, Chrome and Opera. It was wrong in IE6 however. I fixed that. Now it looked the same in all of them. I centred the page and put a nice swirly background on. I looked through all the rest of the site. I noticed that the spacing around the horizontal lines was different in IE than all the rest. I fixed that as well. To do this I had to write a “hack” in the css so that IE would read one bit of css and everything else would read the rest.

Then I had a look at the page in IE5.5. Why? Because from the logs I could see one user using IE5.5. This turned out to be the client….. What a mess in IE5.5. Font sizes all too big. Like being shouted at. I found another hack that fixed this.

Finally, had a look at the site through Safari. And it looked…….fine! So, the site looked the same in all the likely browsers, and the unlikely ones as well. (I know, I haven’t tried IE8 yet.)

OK, here’s the moral of this story. The client likes the new swirly borders, although he won’t see them using IE5.5 and a screen resolution of 800 by 600. Otherwise the site looks pretty much the same as it did 2 months ago despite being completely rewritten. Nobody but me has looked at the site in Chrome or Opera. It’s probably still got some issues I haven’t understood yet. I know a LOT more about css and html. The web pages have still got some tables on them, which are debatably holding tabular data.

The client is still happy…

If you’re looking for some hints and tips on browser consistency then I’ve pulled together some more details on this page.

Tags:

Useful? Interesting? Leave me a comment

I've yet to find a way of allowing code snippets to be pasted into Wordpress comments - so if you're trying to do this you'd be better off using the contact form.