html - 什么是 <meta http-equiv ="Content-Type"content ="text/html; charset=utf-8"/>?

标签 html visual-studio

当我在 Visual Studio 2017 中创建一个新的 Html 文件时,这个:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta charset="utf-8" />

总是出现在 <head> .

没有它,程序运行得很好。那么,有人可以告诉我它有什么作用吗?

最佳答案

根据 HTML Dog :

The charset attribute can be used as a shorthand method to define an HTML document's character set, which is always a good thing to do. <meta charset="utf-8"> is the same as <meta http-equiv="content-type" content="text/html; charset=utf-8">.


所以它基本上用于定义 HTML 文档的字符集。
Visual Studio 2017 添加这两个元标记的原因可能是因为这样您的 HTML 将最大程度地与旧浏览器兼容。<meta http-equiv="content-type" content="text/html; charset=utf-8">是定义字符集的旧方法。<meta charset="utf-8">是做同样事情的新的和更短的方法。

关于html - 什么是 &lt;meta http-equiv ="Content-Type"content ="text/html; charset=utf-8"/>?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51006665/

相关文章:

html - 在 iPhone 中使用短信 url 向多个收件人发送短信

.net - 如何构建类似 Visual Studio 的 UI?

c# - MVC 2 与 VS 2010 View 构建错误 : Feature 'anonymous types' cannot be used because it is not part of the ISO-2 C# language specification

visual-studio - 我如何通知依赖项目在使用 ProjectReference 时必须将输出复制到本地?

javascript - jQuery 子窗口通知父窗口

html - 页面在本地看起来不错。但是当推送到服务器时,一切都会放大

javascript - HTML 评论框自动不增加高度

html - 如何在小屏幕尺寸下将标签放在它们之间

c++ - 如何调试 Visual C++ 运行时错误

visual-studio-2010 - 如何从 TFS 控制下的项目中删除空文件夹?