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 '16 at 17:27
  • Thanks for your answer, my supervisor wants a IE8 compatible website. – Pascal Goldbach Apr 6 '16 at 20:21

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.

| improve this answer | |
  • Why not adding your code directly in html head section instead of using php? – Kitase88 Apr 15 '16 at 17:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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