The following methods can be used to add CSS for specific versions of IE:

  1. Paste the code into html.tpl.php:

    <!--[if lt IE 9]><link type="text/css" rel="stylesheet" src="/sites/all/themes/mytheme/less/ie.css"><![endif]-->

  2. Make use of the plugin Conditional Styles

  3. Use drupal_add_css() function

I have always used option #1 above, and adding yet another plugin for something so simple seemed crazy. BUT working with LESS and calling in statically means the file does not get processed by the LESS pre-processor, so the question:

How do you include a stylesheet using drupal_add_css() for specific versions of IE?

1 Answer 1


I Found the solution in the comments on the drupal documentation for drupal_add_css():

  path_to_theme() . '/less/ie.less',
    'browsers' => array(
      'IE' => 'lte IE 9',
      '!IE' => FALSE

Using this resulted in the LESS file being compiled by the LESS pre-processor, and the style was included within <!--[if lte IE 9]> comment tags.

  • 3
    Wait. So you're telling me there's an automatic LESS pre-processor for Drupal? Yes there is. Awesome. That's 2 answers in one my friend. Thanks. Link: drupal.org/project/less
    – Mario Awad
    Jan 14, 2014 at 10:44

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.