注释掉 HTML 文档中的样式表以支持旧版浏览器
我一直在阅读一些相当老的书来学习CSS。我注意到他们中的大多数人建议像这样编写样式声明,以保持与不支持 CSS 的“旧版浏览器”的向后兼容:
<style type="text/css"><!--
(style declarations)
--></style>
所以我的问题是,这是否仍然是普遍建议的做法(并且仍然如此)真的用过),考虑到现在几乎没有人使用无法处理样式声明的旧浏览器?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
所以我的问题是,这仍然是仅在货物崇拜教程中
是的,但没有任何有用的效果。它们在当时很有用,而且现在(十五年后)不会消亡。
在 HTML 中它们毫无用处。在 XHTML 中,它们是非常有害的(因为脚本元素在 XHTML 中不包含隐式 CDATA,因此如果文档被解析为 XHTML,那么它们将充当实际注释并在浏览器中隐藏脚本)。
Only in cargo cult tutorials.
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.
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).