IE conditional comments for HTML class? I need to have the following html classes with IE conditional comments in my Drupal 8 site: 

&lt;!--[if lt IE 9]&gt;      &lt;html class="no-js lt-ie10 lt-ie9"&gt; &lt;![endif]--&gt;
&lt;!--[if IE 9]&gt;         &lt;html class="no-js lt-ie10"&gt; &lt;![endif]--&gt;
&lt;!--[if gt IE 9]&gt;&lt;!--&gt;
&lt;html class="no-js"&gt;
&lt;!--&lt;![endif]--&gt;


Ideally I would use html_attributes.addClass see this question: Safe to add a class attribute to the HTML element via the theme? 

I tried this: 

&lt;!--[if lt IE 9]&gt;      &lt;html{{ html_attributes.addClass('no-js lt-ie10 lt-ie9') }}&gt; &lt;![endif]--&gt;
&lt;!--[if IE 9]&gt;         &lt;html{{ html_attributes.addClass('no-js lt-ie10') }}&gt; &lt;![endif]--&gt;
&lt;!--[if gt IE 9]&gt;&lt;!--&gt;
&lt;html{{ html_attributes.addClass('no-js') }}&gt;
&lt;!--&lt;![endif]--&gt;


But it seems once you add a class to html_attributes then its printed every time, so my final instance which should only have a class of no-js instead has this: 

no-js lt-ie10 lt-ie9 no-js lt-ie10 no-js
Your best bet is to print the class attributes separately, and use the without twig filter, then hard code the IE stuff, e.g.

&lt;!--[if lt IE 9]&gt; &lt;html{{ html_attributes|without('class') }} class="{{ html_attributes.class }} lt-ie10 lt-ie9"&gt; &lt;![endif]--&gt;
&lt;!--[if IE 9]&gt;    &lt;html{{ html_attributes|without('class') }} class="{{ html_attributes.class }} lt-ie10"&gt; &lt;![endif]--&gt;
&lt;!--[if gt IE 9]&gt;&lt;!--&gt;
&lt;html{{ html_attributes.addClass('no-js') }}&gt;
&lt;!--&lt;![endif]--&gt;



https://www.drupal.org/node/1823416
https://www.drupal.org/docs/8/theming/twig/filters-modifying-variables-in-twig-templates