Conditional class on  element a la boilerplate
There isn't really a great way to do this: Drupal 7 modified drupal_add_css() to make adding conditional CSS possible outside the template file, but not for arbitrary HTML.  Drupal 6 doesn't have anything.

In Drupal 6, and for arbitrary conditional HTML, you either need to add the markup directly  to page.tpl.php, or you could create a variable in your theme's implementation of template_preprocess_page() that contains the relevant markup as a string:

Drupal 7

function foo_preprocess_html(&amp;$variables) {
  $htmlvar = 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .
    $variables['language']-&gt;language . '" lang="' .
    $variables['language']-&gt;language . '" dir="'. $language-&gt;dir .'"';

  $variables['conditional_html'] = '&lt;!--[if lt IE 7 ]&gt; &lt;html class="ie6"' . $htmlvar . '&gt; &lt;![endif]--&gt;';
  // Concactenate the rest of the conditional HTML here
}


Then add $condtional_html to the appropriate place in html.tpl.php.

Drupal 6

function foo_preprocess_page(&amp;$variables) {
  $htmlvar = 'xmlns="http://www.w3.org/1999/xhtml" xml:lang="' .
    $variables['language']-&gt;language . '" lang="' .
    $variables['language']-&gt;language . '" dir="'. $language-&gt;dir .'"';

  $variables['conditional_html'] = '&lt;!--[if lt IE 7 ]&gt; &lt;html class="ie6"' . $htmlvar . '&gt; &lt;![endif]--&gt;';
  // Concactenate the rest of the conditional HTML here
}


Then add $condtional_html to the appropriate place in page.tpl.php.



If you're interested in Drupal 7's conditional CSS handling, you can see Bartik's implementation of template_preprocess_html() for an example:

function bartik_preprocess_html(&amp;$variables) {
  // ...

  // Add conditional stylesheets for IE
  drupal_add_css(path_to_theme() . '/css/ie.css', array('group' =&gt; CSS_THEME, 'browsers' =&gt; array('IE' =&gt; 'lte IE 7', '!IE' =&gt; FALSE), 'preprocess' =&gt; FALSE));
  drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' =&gt; CSS_THEME, 'browsers' =&gt; array('IE' =&gt; 'IE 6', '!IE' =&gt; FALSE), 'preprocess' =&gt; FALSE));
}