简体   繁体   中英

Should meta tags be HTML-encoded?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM