HTML5< meta>标签的属性对旧浏览器的影响 [英] HTML5 <meta> tag's attributes effects on older browsers

查看:195
本文介绍了HTML5< meta>标签的属性对旧浏览器的影响的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的标记具有简单的HTML5兼容< meta> 标记,如下所示:

My markup has the simple HTML5 compatible <meta> tag like so:

<meta charset="UTF-8">

该文档在HTML5文档类型下验证良好,但有什么缺点,如果有的话,使用这个对于旧版浏览器的方法?

The document validates well under the HTML5 doctype, but what disadvantages, if any, are there to using this method when it comes to older browsers?

虽然IE8及以下版本占市场份额的一小部分,但它们仍然存在,特别是在企业环境中。我发现自己最近越来越频繁地为这些企业环境制作网站,并且对于向后兼容性的正确程序感到好奇。搜索引擎优化通常不是一个高优先级,因为这些主要是我正在使用的仅供内部使用网站。

While IE8 and below make up a small percentage of the market share, they do still exist out in the wild, especially in corporate environments. I am finding myself lately producing sites for these corporate environments more and more often and am curious as to what the correct procedure is for backwards compatibility. SEO is generally not a high priority as these are mostly "internal use only" sites that I am working with.

使用的优缺点是什么

< meta charset =UTF-8>

over

< meta http-equiv =Content-Typecontent =text / html; charset = utf-8>

反之亦然?

推荐答案

没有已知的缺点。我刚刚使用IE 6测试(在虚拟XP机器中),它管理< meta charset = utf-8> 罚款。而且你现在几乎找不到比旧版浏览器更旧的浏览器了。

There are no known disadvantages. I just tested with IE 6 (in a virtual XP machine), and it manages <meta charset=utf-8> fine. And you can hardly find an older browser than that in the wild these days.

这并不奇怪,因为在观察浏览器实际解析HTML之后如何将构造添加到HTML5中。这在从中提取字符编码一节中进行了描述。 HTML5 CR中的元元素。浏览器实际上只是在标记中搜索 charset = ,然后在该字符串后面读取编码名称。这意味着,例如< meta sdvhnizfbvjkfhifgb¤¤#%#charset =utf-8> 也有效,但不是特别值得推荐。

This is not surprising, since the construct was added to HTML5 after observing how browsers actually parse HTML. This is described in section Extracting character encodings from meta elements in HTML5 CR. The browsers effectively just searches for charset= in the tag and then reads the encoding name after that string. This means that e.g. <meta sdvhnizfb vjkfhifgb ¤¤#%#charset="utf-8"> works, too, though it not particularly recommendable.

< meta charset = utf-8> 的优点是简洁,简洁,直观易懂。当输入这样的短字符串时,你很少会犯错,就像你可能会使用更复杂的字符串一样。就像<!doctype html> 最终是一个你可以轻松记忆的文档类型,< meta charset = utf-8> 可以轻松学习和输入。当然,您通常应该使用文档模板或类似工具,但关键是您可以在需要时键入这些结构,而无需咨询手册。

The advantages of <meta charset=utf-8> are simplicity, conciseness, and intuitive understandability. And when typing a short string like that, you will seldom make mistakes like you might do with a more complicated string. Just like <!doctype html> is finally a doctype that you can easily memorize, <meta charset=utf-8> can easily be learned and typed. Of course, you should normally use document templates or similar tools, but the point is that you can type those constructs when needed, without consulting a manual.

这篇关于HTML5&lt; meta&gt;标签的属性对旧浏览器的影响的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆