seriously, you should RARELY need to use browser sniffing.
if your html looks different in different browsers, IMPROVE YOUR HTML.
sniffing browsers is not as easy as you may think. there are many different versions of different browsers, and simply checking for MSIE or Mozilla etc is not going to give you reliable results.
checking for msie will tell you that opera is msie, but obviously it is not.
checking for mozilla will tell you ie is mozilla, but its not.
heres a list of the different user agents, its gigantic.
http://www.psychedelix.com/agents.html
unless you plan to take each and every browser into account, your better off just learning how to write better html code. in fact, your always better off just writing better html.
the first step is to use a valid DOCTYPE that puts browser into standards compliant rendering mode.