I want to use different CSS files for different browser types. Is there any simple HTML code which can detect different types of browsers and include CSS files accordingly?<
There are several different techniques for browser-dependent stylesheets:
1) Like already said, you can use conditional statements to detect IE versions, e.g.
2) If you're using server-side language like PHP, Ruby etc., you can detect browser based on HTTP_USER_AGENT server variable, e.g.
if(preg_match('/^Mozilla\/.*?Gecko/i',$agent)){
print "Firefox user."; $firefox = true;
// process here for firefox browser
}
This technique is powerful because you can detect virtually any browser and based on this you can include (or print, to be precise) any required .css file into your PHP template. E.g.
if ($firefox) print '';
The advantage of this technique is that it occurs earliest, even before the page starts getting sent to user and you can detect browser version very exactly.
3) And of course you can detect browser version with javascript, this requires just a couple variables, e.g.
var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
But the a code analyzing values of this variables should be used, like in this example.