Search code examples
htmlmeta-tagsw3c-validation

meta tags apostroph and Quotation mark


Some seo guy told me that I should not use apostroph in meta-tags, because it is not w3c conform. I tried with several doctypes, transitional, strict , html5... and got no errors shown.

<link rel='canonical' href='someurl' />

So what is right?


Solution

  • See the HTML5 CR, 8.1.2.3 Attributes.

    There are four ways how attributes can be specified:

    • Empty attribute syntax
    • Unquoted attribute value syntax
    • Single-quoted attribute value syntax (using ' (U+0027))
    • Double-quoted attribute value syntax (using " (U+0022))

    So yes, you may use '. In that case, the attribute value may not contain other ' characters (you’d have to encode them).