注释HTML文档中的样式表以支持旧版浏览器

注释HTML文档中的样式表以支持旧版浏览器

本文介绍了注释HTML文档中的样式表以支持旧版浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在读一些相当旧的书籍来学习CSS。我注意到,他们中的大多数建议风格声明这样写,以保持向后兼容不支持CSS的旧版浏览器:

I've been reading some fairly old books to learn CSS. I've noticed that most of them recommend that style declarations to be written like this to remain backwards compatible with "older browsers" that don't support CSS:

<style type="text/css"><!--

(style declarations)

--></style>

所以我的问题是,这是一个普遍建议的做法考虑到现在几乎没有人使用不能处理样式声明的旧浏览器。

So my question is, is this still a generally suggested practice (and is it still really used), considering that practically no one these days uses old browsers that can't handle style declarations?

推荐答案

只有在货物教学。

是,有用的效果。他们是在他们的一天有用的东西,现在(十年半后)只是不会死。

Yes, but not to any useful effect. They are something that were useful in their day, and now (a decade and a half later) just won't die.

在HTML他们是没用的。在XHTML中,它们是非常有害的(因为脚本元素不包含XHTML中的隐式CDATA,所以如果文档被解析为XHTML,那么它们将作为实际注释,并从浏览器中隐藏脚本)。

In HTML they are useless. In XHTML they are actively harmful (since script elements don't contain implicit CDATA in XHTML so if the document is parsed as XHTML then they will act as an actual comment and hide the script from the browser).

这篇关于注释HTML文档中的样式表以支持旧版浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-05 18:43