If you are a web designer you must know that it's crucial to learn how to detect a browser type and fine tune your design to look the same in using all major browser otherwise you risk losing visitors.
There are many ways to detect a browser type and we will talk in this tutorial how to do it using PHP as a programming language. You will need to have PHP installed on your server and you will also need to be working with a .php file otherwsie it won't work.
The following code stores 3 stylesheets but only one of them will be used to the visitor and that one will be based on the browser type so the PHP code will detect the browser type and output the right stylesheet:
if ($name = strstr ($HTTP_USER_AGENT, "MSIE"))
echo '<link rel="stylesheet" href="ie.css">';
else if ($name = strstr ($HTTP_USER_AGENT, "Netscape"))
echo '<link rel="stylesheet" href="netscape.css">';
echo'<link rel="stylesheet" href="other.css">';
You can always use conditional comments or
little more complicated job (for example if your page looks
somehow in internet explorer 5 and some other way in ie 7)
but there are many cases when you will want to use a simple
method like the one described above.
Thank you for reading,