Latest news and resources from Youjoomla Team.
As web developers we often have to use different CSS techniques for different browser types. Now days every browser has it's own hack but imagine if you have to use custom CSS hack for each browser there is and load html conditional comments for each! That would be to much code in head tag . To keep it neat and load conditional comment only when specific browser is used here is a small PHP snippet that can help keep your code organized.
First we place the browser detection snippet in our index.php file :
$who = strtolower($_SERVER['HTTP_USER_AGENT']);
Than we load the conditional comment to be used only if visitor is using IE6 browser :
if(preg_match("/msie 6.0/", $who)){ echo' <style type="text/css"> #mydiv{ padding:5px; } </style>'; }
To load different style for other browsers simply change the browser name in first line of code
if(preg_match("/chrome/", $who)) {
Here is the list of other browsers you can use:
The Joomla!® name is used under a limited license from Open Source Matters in the United States and other countries.
Youjoomla.com is not affiliated with or endorsed by Open Source Matters or the Joomla! Project.