Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Suggested meta tags for HTML 5 that should be considered a must have

Tags:

html

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> 
like image 430
PeanutsMonkey Avatar asked Aug 01 '12 21:08

PeanutsMonkey


People also ask

Is meta tag required in 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). I know this is old but even the title tag is optional.


2 Answers

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

like image 66
Torsten Walter Avatar answered Sep 17 '22 14:09

Torsten Walter


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.

like image 26
Jukka K. Korpela Avatar answered Sep 18 '22 14:09

Jukka K. Korpela