元标签应该是 HTML 编码的吗?

发布于 2024-09-10 16:06:38 字数 113 浏览 0 评论 0原文

我通常对我在网站上呈现的任何用户生成的内容进行 HTML 编码,因此与符号变为 & 等等。我想知道是否应该对整个网站中任何动态生成的元标记执行此操作(从标准的角度来看)?

I generally HTML-encode any user generated content that I render on my website, so ampersands become & and so on. I was wondering if this should be done (from a standards point of view) to any dynamically generated meta tag throughout a site?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

撞了怀 2024-09-17 16:06:38

绝对地。 HTML 文档中的所有内容都必须以这种方式编码。

Absolutely. All content within the HTML document must be encoded this way.

_畞蕅 2024-09-17 16:06:38

如果您的意思是这样的:

<meta name="description" content="Some stuff, other stuff & even more stuff!" />

是的,您需要将&符号和其他特殊字符编码为实体,以便您的元标记验证。

If you mean something like this:

<meta name="description" content="Some stuff, other stuff & even more stuff!" />

Yes, you need to encode the ampersand, and other special characters, to entities so your meta tags validate.

乖不如嘢 2024-09-17 16:06:38

是的。例如,引号不会关闭元元素的内容属性,这会触发无效的 HTML。

Yes. So for example quotes don't close the content attribute for a meta element which would trigger invalid HTML.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文