How do I detect the user’s browser and apply a specific CSS file? -


i need detect browser , apply matched css file.

i have created 3 css files: __ie.css, ff.css, opera.css. need detect browser in order include one.

i know

<!--[if ie]>      <link rel="stylesheet" href="css/ie.css" type="text/css"/> <![endif]--> 

but how do same firefox , opera/chrome?

if have detect browsers apply css, might want rethink css before going browser-specific stylesheets. takes 1 browser mimic another's user agent string, or new version released, , breaks. use current standards , validate code (http://validator.w3.org/), , you'll have worry far fewer cross-browser issues. using <!--[if ie]><![endif]--> without version number break layout in later versions.

that being said, if want style page differently based on css features available, take @ modernizr. way, you're checking features, won't broken if new version of browser released.

if else fails , need detect visitor's browser, try jquery.browser. it's built jquery, , simple use. http://api.jquery.com/jquery.browser/.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -