I use a responsive template which works great on most browsers, but on some older browsers like IE8 some elements doesn't display correctly, so I wanted to create a custom CSS file for Internet Explorer.

How can I import IE-Only stylesheets the proper way? I could add a condition like <!--[if lt IE9]> ... <![endif]--> directly in the template but I don't know if there's a better solution.

Thank you in advance.

  • 1
    IE8 is Gone the Way of the Dodo, So Why Support a Dying Species?
    – Mikan
    Apr 6, 2016 at 17:27
  • Thanks for your answer, my supervisor wants a IE8 compatible website. Apr 6, 2016 at 20:21

1 Answer 1


Finally I added this code near the beginning of my index.php file (located in my template folder).

$doc = JFactory::getDocument();
$stylelink = '<!--[if lte IE 8]>' ."\n";
$stylelink .= '<link rel="stylesheet" href="linkOfTheCSSFile/ie7.css" type="text/css"/>' ."\n";
$stylelink .= '<![endif]-->' ."\n";


It works great for me.

  • Why not adding your code directly in html head section instead of using php?
    – Kitase88
    Apr 15, 2016 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.