Trying to leverage drupal_add_html_head to add an ie10 class Since IE10 does not understand conditional comments, I can't use the typical methods to single out that browser. However, I found a nice function that works well and if I add this to html.tpl.php in my theme:

&lt;script&gt;if (Function('/*@cc_on return document.documentMode===10@*/')()){
    document.documentElement.className+=' ie10';
  }
 &lt;/script&gt;


... it works for IE10 and adds an HTML class of ie10. 

But for best practices, I really want to use a preprocess function. So I looked at drupal_add_html_head and that seems to be the ticket. But when I formulate my code as such:

function MYTHEME_add_html_head($element, $inline_script) {

  $inline_script = &lt;&lt;&lt;EOL
  &lt;script&gt;if (Function('/*@cc_on return document.documentMode===10@*/')()){
    document.documentElement.className+=' ie10';
  }
  &lt;/script&gt;
EOL;
$element = array(
'#type' =&gt; 'markup',
'#markup' =&gt; $inline_script,
);
drupal_add_html_head($element, 'system_ie_browser');
}


... it does not work. There does not seem to be a lot of documentation around this and I could not really find anyone else doing exactly what I need so I'm a bit lost here. I replaced MYTHEME with the actual theme machine name and cleared cache too. 

What I'm not sure about is if this part...

drupal_add_html_head($element, 'system_ie_browser');


... is significant in terms of Drupal understanding it and where to put it. I don't know if there are specific variables that go there. I just sort of made system_ie_browser up.
Hope this will help you,

Use Browser class module.


  This small module helps theme-developers to deal with cross-browser compatibility. It makes easier to handle different types of non-widespread browsers just as much as it helps with using different versions of Internet Explorer.
  The module extends the $body_classes variable in page.tpl.php based on the enduser's browser, and platform.
  
  The module also makes a $browser_classes variable available in page.tpl.php, which stores the data in an array, this way the developer can make use of it as needed, if he does not wish to use the $body_classes variable.