Index: wp-includes/general-template.php
===================================================================
--- wp-includes/general-template.php	(revision 13164)
+++ wp-includes/general-template.php	(working copy)
@@ -1884,11 +1884,15 @@
 		$attributes[] = "dir=\"$dir\"";
 
 	if ( $lang = get_bloginfo('language') ) {
-		if ( get_option('html_type') == 'text/html' || $doctype == 'html' )
-			$attributes[] = "lang=\"$lang\"";
-
-		if ( get_option('html_type') != 'text/html' || $doctype == 'xhtml' )
+		// if doctype is passed as xhtml, use only xml:lang, that is supported by all XHTML versions
+		if ( $doctype == 'xhtml' )
 			$attributes[] = "xml:lang=\"$lang\"";
+		// if MIME is not text/html, use xml:lang too
+		elseif ( get_option('html_type') != 'text/html' )
+			$attributes[] = "xml:lang=\"$lang\"";
+		// if doctype is not passed as xhtml and MIME is text/html, then use lang
+		else
+			$attributes[] = "lang=\"$lang\"";
 	}
 
 	$output = implode(' ', $attributes);
