度ei它

<!DOCTYPE html> 是 HTML5 中唯一的 doctype,也被视作将网页 "升级" 到 HTML5 的第一步。

很多国外网站的 <!DOCTYPE html> 和 <HEAD> 之间都会有一段注释,如:

<!—[if IE 6 ]><html class="ie ielt9 ielt8 ielt7 ie6" lang="en-US"><![endif]—>
<!—[if IE 7 ]><html class="ie ielt9 ielt8 ie7" lang="en-US"><![endif]—>
<!—[if IE 8 ]><html class="ie ielt9 ie8" lang="en-US"><![endif]—>
<!—[if IE 9 ]><html class="ie ie9" lang="en-US"><![endif]—>
<!—[if (gt IE 9)|!(IE)]><!—><html lang="en-US"><!—<![endif]—>

改代码作用于 css,来写一些针对 IE 各版本的样式差异。

先判断用户用的哪个 IE 版本,然后在标签上加上该版本的 class,这样可以方便 hack。

css 文件是这样写的:

.ie6 xxx {};
.ie7 xxx {};

这是目前最好的 hack 方式之一。