Search code examples
htmlsymbolsmetahtml-entitieshtml-encode

Should HTML character codes or the symbols be used in the meta description?


Can symbols like and ® go directly in the meta-description tag, or should their HTML character codes be used?

<meta name="description" content="Hello® World™">

<meta name="description" content="Hello&reg; World&trade;">

Solution

  • If the character encoding of the HTML document allows it, use the characters directly. The HTML spec recommends to use UTF-8 ("Authors should use UTF-8."), which is an encoding that allows this.

    Relevant article from the W3C Internationalization Working Group:
    Using character escapes in markup and CSS

    Some escapes are required

    You must still use entities for characters that have a reserved meaning in HTML, if the context makes them ambiguous.

    Examples:

    • < (as &lt;)
    • > (as &gt;)
    • & (as &amp;)
    • " (as &quot;)
    • ' (as &apos;)

    Some optional escapes are useful

    It can be a good idea to use entities for invisible characters (other than the common ones for space, tab, and new line), so that authors don’t confuse/overlook them.