Acting upon browser specific differences

In the ideal world all browser would act confirm to the w3c standards. But this is not an ideal world so as you are designing a page not all browsers render the same code in the expected way.

My question is quite clear: how do you act upon such situation ?

Currently I’m using javascript to check which browser is viewing the page.

if IE
<sometag style=“some_style”/>
else if firefox
<sometag style=“different_style”/>

But I’m guessing there are better way’s to come around such issues ?


which is why the gods invented conditional comments

AhA! We’ve caught you! Calling the guys at M$ gods! Muhahahahaha… : ) [/ot]

I think Alex hit it on the head. :slight_smile:

I just figured they had goats ears or something…

I file bugs with the relevant browser vendor(s).

Why do people still think that cross browser coding is hard work? It’s not like we’re in the days where your options were IE5x, IE6, IE7 and really raw versions of Mozilla Suite, Safari and Opera (bouncing around happily). It’s VERY rare these days to have something that seriously screws up against the latest iterations of browsers. If it works in Firefox, it’s pretty much going to work in Opera, Chrome, Safari and IE9 without too much hassle… and IE6-8 just require the odd small-time push in the right direction (which is why the gods invented conditional comments). Making a cross compatible site has never been easier and doesn’t require those ole nasty hacks. :slight_smile:

That is just as evil as browser sniffing. Your web page WILL look slightly different in different browsers. You are NOT in control of this and there is NOTHING you can do about it, it just is. Design your web pages with these facts in mind.

You have NO control over the user’s fonts. You can only suggest, you cannot control.

I find that a quite complicated approach. It is nearly impossible to have a different stylesheet for each browser. I try to solve it in just one stylesheet

If you stick to clean, well-structured and straightforward code, you should have very few browser problems. Browser “sniffing” went out of fashion a long time ago. It would be better to rethink the way you are coding sites than resort to JavaScript for such purposes.

Ideally, set up a means for testing your designs step by step as you build them in all of the major browsers. There are online services for this, or you can set up virtual machines (Mac is particularly handy as you can run Windows on it) or have a spare computer for testing…

They actually invented them to make transferring files between different versions of Microsoft Office easier. That they can also be used to make catering for old versions of IE easier is just an accident.

[ot]AlexDawson: “Gods can be bad - in Pagan mythology there’s plenty of cases…”

Odysseus: “Yeah, man, tell me about it…”[/ot]

Stomme: Gods can be bad - in Pagan mythology there’s plenty of cases of them still qualifying for the position.

I like to think of Microsoft being alike the Egyptian god (of the desert, storms, darkness, and chaos) Set … sounds about right doesn’t it? :smiley:

Does give a nice font in firefox but gives me a completely different , kinda rasterized font in IE.




With my default OS settings on my VirtualBox Windozen, I have the opposite: IE looks great, all non-IE browsers look like crap (no anti-aliasing).

Since this is due to how users have configured their computers and not their browsers, you can’t Java-junk your way out of that one anyway.

Another reason I surf with the stuff off.

If I can’t tell if the bug’s been filed before, I don’t bother. I might be reporting a new bug, or I might be reporting something 10 other people have already done, and therefore I’d be wasting my time. So I only bother with open bugzilla-style bug reporting.

You can’t use JavaScript to hack for which font to use. Anyway with that CSS both browsers are going to use the exact same font with the only difference being browser settings that have nothing whatever to do with which browser that it is.

You should never just list one font in the CSS anyway - you should always list several so that anyone without the first font installed has a fall back font of your choice to use rather than their system default.

But what about situations like this one:

font-family: “courier”;

Does give a nice font in firefox but gives me a completely different , kinda rasterized font in IE.
Do I need to compromise and use “courier new” which works fine in both browsers but isn’t my prefered font, instead of using Javascript to hack on this issue ?

As you gain experience you learn to code with one stylesheet that works across browsers. There may be a couple three hacks in there for IE but nothing major.

I do include some CSS3 in my styles that degrades gracefully in IE

It went out of fashion long before that. It never was in fashion in JavaScript since JavaScript has always supported feature sensing for determining whether a particular command is supported or not. Even the early dinosaurs used to tell one another that browser sniffing was bad for you. Also it will not fix things for old versions of IE anyways since only an idiot would have JavaScript enabled in IE6 since IE6 contains hundreds of activex security holes and so you must turn off activex to secure that browser and if you do that without also turning off JavaScript you get warning popups about activex being disabled on every page.

The simplest way to get things consistent across all browsers is to write the code in accordance with the W3C standards, That will take care of all moredn browsers and only antique browsers such as IE7 can have any significant problems. Those can then be fixed using Microsoft conditional comments to add an extra stylesheet just for that browser. The same applies to earlier versions of IE as well if you have any dinosaurs accessing your site using those versions of IE.

If you take IE6 and IE7 out of the equation for the moment, all other current browsers are remarkably consistent, and there are very few occasions when they will act so differently that it needs a fix.

Currently I’m using javascript to check which browser is viewing the page.

:mad: Evil :x: Evil :crazy: Evil :bomb: Evil :redhot:

There are many reasons that browser sniffing went out of fashion in the fifteenth century, not least of which is that you will without fail end up telling people their browser is out of date and doesn’t support the site, or serving them dull and basic content, when their browser does support every feature used. As a long-standing Opera user, this bugs me greatly.

Pretty much all you need to do is the occasional star-hack or conditional comment to target old versions of IE. There should be no need for any browser sniffing beyond that if you are using recommended coding practices.