38

I am looking at migrating over pages written in XHTML 1.0 to HTML 5 and am looking at the minimum requirements when including meta tags in the <head> element. For example, my current page which is XHTML 1.0 compliant has the following meta tags

<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta http-equiv="content-language" content="en-us" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="copyright" content="&copy; 2012" />
<meta name="robot" content="noindex, nofollow" />

Are the following sufficient for HTML 5 and can I also include them?

It is also my understanding that the meta element <meta http-equiv="content-language" content="en-us" /> can now be globally be applied to the <html> element.

<html lang="en-us">
<head>
<meta charset="UTF-8" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="pragma" content="no-cache" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta name="author" content="" />
<meta name="copyright" content="&copy;" />
<meta name="robot" content="noindex, nofollow" />
<title>sample code</title>
</head>
</html>

3 Answers 3

27

There is no such thing as minimum meta tags (unless of course I got your question wrong). As far as I am aware no meta tag is required and the ones you add are the ones for your specific needs.

Consider the following document:

<!DOCTYPE HTML>
<html>
    <head>
        <title>Some Title</title>
    </head>
    <body>

    </body>
</html>

You can validate it and not get any warning whatsoever. The validator just reminds you that the default encoding is missing. This is not even a warning, just an information.

The working draft has this to say about meta tags:

The meta element represents various kinds of metadata that cannot be expressed using the title, base, link, style, and script elements.

And it goes on:

4.2.5.1 Standard metadata names

application-name, author, description, generator, keywords

Further it mentions some additional tags concerning a page's status, contextual representation and character encoding.

Although none of these ar explicitly required by the standard, there are in fact best practices, especially concerning search engine optimization (SEO). This has nothing to do with the HTML standard but with web (search) crawlers.

You can get some good advice which meta tags matter (for Google) at the Webmaster Tools meta tag support page

7
  • 1
    Thanks. If there is no such thing as a minimum what is recommended that covers scenarios such as SEO, browser support, etc? Commented Aug 1, 2012 at 21:35
  • Of course then I think what you have is spot on. I can only think of the canonical url URL meta tag that I would add too. But that is completely unrelated to HTML5 and didn't change since XHTML. Commented Aug 1, 2012 at 21:38
  • What do you mean by completely unrelated? Commented Aug 1, 2012 at 21:56
  • 1
    The validator does not issue a warning about any missing meta tag. The message “No Character encoding declared at document level” is labeled as informative. Commented Aug 1, 2012 at 22:22
  • @JukkaK.Korpela, for what it's worth, checking the same document with direct input also just gives me the information about the missing charset. Using the upload validator I get a warning. @PeanutsMonkey, with unrelated I was referring to that <meta> is just a tag defined in the html standard as having a name and content attribute. What you put into those attributes is up to you or better the user agents you are going to serve. Commented Aug 2, 2012 at 8:55
7

According to http://validator.w3.org/ the following is an absolutely minimal example of a valid HTML5 document, literally everything else is optional.

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>Valid HTML5 Document!</title>
</head>
</html>

So, you absolutely must have the charset meta tag defined, and everything else is a matter of accomplishing your goals (search engine related stuff, cache control, etc).

3
  • Actually the <meta charset='xxx'> is optional. The validator just issues an information: It is often recommended to declare the character encoding [if] the document will be read from or saved to disk, CD, etc. Commented Feb 3, 2014 at 22:18
  • I know this is old but even the title tag is optional.
    – rfcoder89
    Commented Apr 9, 2014 at 16:06
  • Sorry that I don't agree, the <meta charset='xyz'> is indeed a requirement if you are imputing text with latin characters with acutes and tildes, and not only is this important for the correct interpretation of such characters but critical if you are uploading content to a database, otherwise the misinterpretation of the charset can cause all kinds of trouble on your content over browsers. Commented Aug 27, 2014 at 23:59
6

No meta tag is required by any HTML5 draft. (HTML5 is work in progress and may change at any moment without prior notice.)

Many of the tags you list, including the one with content-language, aren’t even allowed (conforming) according to HTML5 drafts. In practice, most of them are useless, but some of them are actively harmful (such as the one that excludes robots, and in most cases those that try to prevent all caching).

Your latter fragment of code is invalid: the html element must contain all other elements, and the head element must contain a title element (in all HTML versions).

Consult the newest W3C HTML5 draft and use the experimental checker http://validator.nu.

3
  • Sorry my bad. I missed out the <title> element. What do you mean by Your latter fragment of code is invalid: the html element must contain all other element? Do you mean <body>, <section>, etc? Commented Aug 1, 2012 at 22:48
  • 1
    I mean you have there the html element after the head element. Commented Aug 2, 2012 at 5:03
  • Sorry. I completely missed that. I was so caught up in thinking about the HTML5 elements that I overlooked the html container. Commented Aug 2, 2012 at 19:15

Not the answer you're looking for? Browse other questions tagged or ask your own question.