Search code examples
htmlvalidationmeta

HTML meta-Tag validation error - restrictions on content?


Are there any restrictions on what may be contained in a meta-tag content?

I have the following meta-tag defined:

    <meta name="doctype" content="<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\" \"http://www.w3.org/TR/html4/strict.dtd\">"/>

Unfortunately, the w3 validator throws an error that doesn't make sence, because the content really is just a string:

"-" is not a member of a group specified for any attribute

Can anyone explain the issue, we need different information in a client-side jQuery script and until now always used different meta-tags.


Solution

  • Are there any restrictions on what may be contained in a meta-tag content?

    It depends on the version of HTML.

    Most versions are pretty relaxed about it. HTML 5 has pretty strict restrictions (albeit ones which include "and anything on this Wiki page" … which no validator that I'm aware of manages to stay up to date with).

    "-" is not a member of a group specified for any attribute

    That is because you can't include a raw " character in an attribute value delimited with " characters. You need to represent it as &quot; (or a numerical character reference).