开发者

Should meta tags be HTML-encoded?

开发者 https://www.devze.com 2023-01-08 05:21 出处:网络
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 s开发者_运维问答hould be done (from a standards point

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 s开发者_运维问答hould be done (from a standards point of view) to any dynamically generated meta tag throughout a site?


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


If you mean something like this:

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

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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消