On TechRepublic: 12 tech terms that make you sound old
BNET Business Network:
BNET
TechRepublic
ZDNet

June 24th, 2008

Why I still prefer Internet Explorer

Posted by John Carroll @ 9:11 am

Categories: Microsoft, Programming, Web Technology

Tags: Opera Software, Mozilla Firefox, Apple Safari, Microsoft Internet Explorer, Web Browser, CSS, Web Browsers, Scripting Languages, Software/Web Development, Web Development

I wrote a blog post last week where I discussed some of the good lessons from the success of Firefox. I truly believe Firefox is a great browser, and I am glad that competition has forced Microsoft to pull its IE developers out of suspended animation to update its ability to handle CSS properly. Let’s just hope there are no H.R. Giger-inspired aliens on board.

Even so, I do approach the reignition of the browser wars with a certain amount of trepidation. Testing across browsers is a royal pain in the butt, and I’m sorry, I don’t care how “standards compliant” Opera, Safari, Firefox or even IE will claim to be, you would be mad not to test your HTML / CSS / Javascript creation in each and every one.

Well, I’m proud to say I’ve done that, and the service on which I have been busily working for the past several weeks renders properly in all of them.

I can’t say, however, that it wasn’t without work, work which I wouldn’t have to worry about if one browser reigned triumphant. One triumphant browser, however, means the browser doesn’t get updated very often. So, thank goodness for competition.

Even so, I did run into some rather unusual problems. And, as it turned out, the problem wasn’t with IE. Rather, it was with Firefox, Safari and Opera.

Some of the pages on the site I am updating were written awhile ago, and used tables for layout. For one of the new screens, however, I decided to write it from scratch to do things the modern “CSS” way. For reasons that Talkback participants have explained to me but I have not yet completely accepted (I think it makes sense to have proper GRID-style layout primitives, and TABLE is used an awful lot that way), that means TABLE tags are out, and DIV tags are in.

The page, in this case, was a page for contact information. Each row had a label, followed to the right by a set of fields related to the labeled functionality. One of the advantages of TABLE tags as a layout primitive is that it spontaneously sizes itself to the content, making it easy to add new rows later. I wanted to maintain that behavior in my DIV-oriented layout, so that I could add new rows and fields with impunity without having to go through and manually recalculate a bunch of fixed-position rows.

To effect this, I created a CSS class called rowAttributes that defined the row as “position: relative” (which is important, as CSS will treat it as the baseline against which all contained positioned divs are interpreted). I then created a class called labelAttributes, which had an absolute position and a fixed width. Last, I created a class called editFieldAttributes, told it to “float: right,” and gave it a fixed width. This isn’t ideal, as I would really rather make the editFieldAttributes position: absolute (relative to the containing row DIV). That, however, causes it to break on all browsers, which is somewhat understandable; absolute positioned divs have no “natural” height to speak of unless you give it one.

You can see a demonstration of the code here (which is, in its essentials, the same as what I am using on my site). The border I have displayed around each row is just there as a sanity check, and shows that the contained divs live properly inside the parent row div. If you run this page in IE, it works, and the border indicates the row properly contains its children. If you run it in Firefox, Safari, or Opera, it doesn’t. In Firefox, Safari and Opera, the label block clearly refuses to live inside its containing row (and all the row border “rubber bands” are clustered together at the top of the block containing the edit fields).

Now, someone is sure to point out that if Firefox, Safari and Opera all consistently fail to render the HTML and CSS, then it is IE that is rendering it “wrong.” Well, that’s like saying that because a room full of teenagers can’t find Iraq on a map, that Iraq does not exist. I’d accept that IE was being overly forgiving if I was doing something illogical, e.g. that I wasn’t putting my labels inside a containing row DIV, or that I tried to allow my absolutely positioned DIVs to have a “natural” height based on the layout of their contents. I’m not doing any of those things.

I’ve tried multiple variants of this code (this one just struck me as the “cleanest”), and all of them worked in IE, while none of them worked in Firefox, Safari or Opera. This is why, as a fallback, I chose just to use absolute positioning for each row. That doesn’t make me happy, but it works consistently across browsers, even if the “rubber band” border shows that the browser is really confused about what the “row” actually contains. That second version (with absolute positioned rows) is the second edit field block in my bit of demo code.

IE started to grate on me when I began to appreciate the power of CSS, and wished IE did a better job of supporting it. IE 7.0, however, does a good job of supporting CSS, at least the bits that I care about. Now I’m back to frustration at the inconsistency across browsers.

By the way, I found healthy numbers of places where rendering was inconsistent between Firefox and Safari or Opera (Safari and Opera seem to be in lockstep from a rendering standpoint). One that springs to mind is its treatment of non-existent style sheets. I had a style sheet that was supposed to only be downloaded for the Chinese version of our old site. To effect this, I just detected the culture within which the page was running, and created a request for a style sheet that was the two-letter language code followed by the .css suffix (for chinese, this was zh.css). For most languages, this file did not exist, which didn’t affect rendering in IE or Firefox one bit.

I’m not saying this is “ideal” code. More efficient code would have been to have some master list of languages that required custom CSS attributes, and only generate the proper CSS-related STYLE tags when the language was one that required it.

In Safari and Opera, however, it interpreted the HTML retrieved for a 404 error code (the code returned when it can’t find a CSS file) as CSS, which can lead to random results. In the case of our pages, it made all the links and buttons (which were actually modified links) look red. It took a bit of research to figure that one out, but it is now resolved.

What’s the takeaway from all this? Open standards are good and important. However, until every browser somehow manages to interpret a massive and complicated standard specification in the exact same way, there is no such thing as perfect consistency. Standards help to make the likelihood higher, but they are no assurance.   There is still going to be strong incentives to pick one browsers as “dominant.”

It’s also worth pointing out where IE is getting it right.

UPDATE:  Talkback participant andrewjg figured out the perfect solution, and it is dazzling in its simplicity;  simply add “clear: both” to the rowAttributes class, and everything magically falls into place (though the “rubber band” border still doesn’t wrap the contents, but that doesn’t matter; I’m not using that on my site, and only added it to help make clear the problem I was trying to describe).

I really do want to do things the CSS way, which is why I went through the trouble of making my new page use DIVs for layout.  This could make it possible.  I haven’t updated my site yet, but this looks promising.

John CarrollJohn Carroll has delivered his opinion on ZDNet since the last millennium. Since May 2008, he is no longer a Microsoft employee. He is currently working at a unified messaging-related startup. See his full profile and disclosure of his industry affiliations.

Email John Carroll

Subscribe to A Developer's View via Email alerts or RSS.

  • Talkback
  • Most Recent of 108 Talkback(s)
Elegantly Correct
I have looked at Mr. Carrol's work and I find it both elegant and correct, and conforming to codified structure.
It SHOULD display correctly on any browser having sufficient sophistication to read ... (Read the rest)
Posted by: Otis Driftwood Posted on: 02/28/09 You are currently: a Guest | | Terms of Use
Well everybody is entitled to their opinion  Michael Kelly | 06/24/08
I am a programmer  John CarrollZDNet Moderator | 06/24/08
The solution I use as a developer...  DonRupertBitByte | 06/24/08
Amen to that  Len Rooney | 06/24/08
Flash in the UI -- UGH!  bhartman33@... | 06/24/08
Not for my industry/job  DonRupertBitByte | 06/24/08
Thanks happy  bhartman33@... | 06/24/08
Flex makes it a doodle  Richard Flude | 06/24/08
But it's that glorified frame  Michael Kelly | 06/24/08
I am a programmer  rigo12 | 07/04/08
You are also a Microsoft SHILL!  AdventTech67 | 07/23/08
Chateaubriand not McDonalds  johnfenjackson@... | 06/24/08
I.E. 8  TripleII | 06/24/08
Nope  John CarrollZDNet Moderator | 06/24/08
Well, now ... grin  TripleII | 06/24/08
I'd like to see a drawing...  storm14k | 06/24/08
I didn't absolutely position everything  John CarrollZDNet Moderator | 06/24/08
I did in the blog  John CarrollZDNet Moderator | 06/24/08
Testing in IE 8  mswift@... | 07/03/08
RE: Why I still prefer Internet Explorer  cameljockey | 06/24/08
Makes sense to programmers....  John CarrollZDNet Moderator | 06/24/08
I'm a programmer...  storm14k | 06/24/08
No Way!  TripleII | 06/24/08
I did in the blog  John CarrollZDNet Moderator | 06/24/08
I'm hardly new to CSS layout  John CarrollZDNet Moderator | 06/24/08
I gathered it all from your article...  storm14k | 06/24/08
I use CSS all the time...  John CarrollZDNet Moderator | 06/24/08
Attempting to visualize...  storm14k | 06/24/08
The W3C validation service  deaf_e_kate | 06/25/08
Your analogy sucks  glocks out | 06/24/08
Safari, Opera and Firefox  John CarrollZDNet Moderator | 06/24/08
Self-limitation  tikigawd | 06/25/08
People of No Significance  Semantic | 06/25/08
I realize it is hard...  John CarrollZDNet Moderator | 06/25/08
Dealing with browsers  CobraA1 | 06/24/08
Nice Site  Bozzer | 06/24/08
Hm, what does the standard say?  DevGuy_z | 06/24/08
Fair enough....  John CarrollZDNet Moderator | 06/24/08
Don't feel bad  j.m.galvin | 06/24/08
Part of the problem...  John CarrollZDNet Moderator | 06/24/08
Part of the problem  WATKINS12@... | 06/25/08
Only what the standards makers choose to say.  Anton Philidor | 06/24/08
It looks like a browser implementation  deaf_e_kate | 06/25/08
Amaya  Yagotta B. Kidding | 06/24/08
Happens to me too  Roger Ramjet | 06/24/08
RE: Why I still prefer Internet Explorer  Jaril | 06/24/08
Conventional wisdom...  John CarrollZDNet Moderator | 06/24/08
replying in Firefox browser  Maarek | 06/24/08
Growing tired of this  John CarrollZDNet Moderator | 06/24/08
I tried to like IE but ...  LBiege | 06/24/08
Multi-tabs were hard to implement in IE 7...  Anton Philidor | 06/24/08
My small advice  tombalablomba | 06/24/08
That would be normal behavior  John CarrollZDNet Moderator | 06/24/08
By the way...  John CarrollZDNet Moderator | 06/24/08
Gets it a little closer  dragosani | 06/24/08
So it does  John CarrollZDNet Moderator | 06/24/08
FYI  dragosani | 06/24/08
Solution  andrewjg | 06/24/08
LOL  dragosani | 06/24/08
The holy grail  John CarrollZDNet Moderator | 06/24/08
RE: Why I still prefer Internet Explorer  andrewjg | 06/24/08
Please, post an exemplar?  John Le'Brecage | 06/24/08
Semantic markup  andrewjg | 06/24/08
Productivity  Yensi717 | 06/24/08
I agree  andrewjg | 06/24/08
Problems with the details  tonymcs@... | 06/24/08
Tolerating faults  Anton Philidor | 06/24/08
In this case, though...  John CarrollZDNet Moderator | 06/25/08
Firefox 3 is buggy  cruggeld | 06/25/08
!(Firefox 3 is buggy)  AndyCee | 06/25/08
The opposite happened to me  davidr69 | 06/25/08
Try it in IE8  andrew53 | 06/25/08
That's cos it's more standards compliant...  GOTBO | 06/25/08
RE: Why I still prefer Internet Explorer  1337pc.net | 06/25/08
I did  John CarrollZDNet Moderator | 06/25/08
Check out the versions also!  GOTBO | 06/25/08
I"ve had that problem too....  John CarrollZDNet Moderator | 06/25/08
RE: Why I still prefer Internet Explorer..HEE HEE  wallis2004 | 06/25/08
Have you seen my code?  John CarrollZDNet Moderator | 06/25/08
A simple trick to remember  Mitch 74 | 06/25/08
the viewers browser...  aussiedawg | 06/25/08
How is that possible  alterbridgeandrew@... | 06/25/08
As noted...  John CarrollZDNet Moderator | 06/25/08
RE: Why I still prefer Internet Explorer  Ibtrubl@... | 06/25/08
Only virus creators still prefer Internet Explorer (nt)  rebelxhardcore | 06/25/08
RE: Why I still prefer Internet Explorer  An Old Man | 06/25/08
Did I say I disliked CSS?  John CarrollZDNet Moderator | 06/25/08
RE: Why I still prefer Internet Explorer  TedKraan | 06/25/08
RE: Why I still prefer Internet Explorer  2max67 | 06/25/08
RE: Why I still prefer Avant????  oregonnerd13 | 06/25/08
RE: Why I still prefer Internet Explorer  El Condor | 06/25/08
RE: Why I still prefer Internet Explorer  El Condor | 06/25/08
RE: Why I still prefer Internet Explorer  black-jack | 06/25/08
This works. Safari, FF3, IE6  pinxi | 06/25/08
clear only part the answer  pinxi | 06/25/08
Strangely, looks the same in SeaMonkey as in IE  seanferd | 06/25/08
Ignorance  emenau | 06/25/08
RE: Why I still prefer Internet Explorer  ratz2 | 06/26/08
RE: Why I still prefer Internet Explorer  swathingscientist | 06/26/08
RE: Why I still prefer Internet Explorer  jfreedle2@... | 06/28/08
This guys should seriously try the Acid2 and 3 tests  ardnivar | 07/02/08
I helped design  kcredden2 | 07/02/08
RE: Why I still prefer Internet Explorer  frabjous | 07/03/08
RE: Why I still prefer Internet Explorer  skim56732@... | 07/03/08
RE: Why I still prefer Internet Explorer  _JimB_ | 07/03/08
RE: Why I still prefer Internet Explorer  rob07601 | 07/06/08
RE: Why I still prefer Internet Explorer  bapu.mohapatra@... | 07/09/08
Elegantly Correct  Otis Driftwood | 02/28/09

What do you think?

SponsoredWhite Papers, Webcasts, and Downloads

advertisement

Recent Entries

Top Rated

Archives

ZDNet Blogs

White Papers, Webcasts, and Downloads

  • Smart Tech Expert advice on innovations in healthcare and the green technologies that make it happen. Find out more
  • Smart Business Discussion and advice on management issues that revolve around making your world smarter and more useful. More Smart Advice
  • Smart People The best and worst moves in the management and strategy trenches. Learn More