What happens if the meta tags are present in the document body?

If your aim is search engine optimization, then it is probably a good idea to follow the standards and put all your meta tags in the <head>. However, as far as browser behavior goes, if you place <meta> tags into your <body> they will still function. I decided to test this using multiple <meta http-equiv="refresh"/> tags and <title> tags in an otherwise standards-compliant document.

The results of my tests:

Firefox 18, Firefox 3.6, Firefox Mobile, Chrome 24, Chrome for Mobile, Opera 12, IE6, IE8, IE10:

  • All <meta> tags in the body were processed.
  • The first <title> tag in the document was processed, even if it was in the body. Subsequent <title> tags were ignored.
  • The earliest meta refresh directive took effect, implying that both were processed.

IE9:

  • Same as above, except all <title> tags in the body were ignored.
  • IE10 in IE9 Standards mode also behaves like this.
  • IE9 in IE8 Standards mode behaved the same as IE8, allowing 1 <title> tag in the body.

So, what happens when you use meta tags in the body? By and large, they seem to work fine. The meta tags will probably be processed, so if you can't put them in the head then I wouldn't fret too much.


The bottom line is to avoid this whenever possible when the DOCTYPE forbids it. I think this is definitely permitted in HTML5 and very useful in cases using microdata. Example: http://schema.org/Event


This is of course invalid as per HTML4.01. META tags are only allowed within HEAD (just like, say, TITLE) so by putting it into a BODY, you're essentially creating an invalid markup.

From the cursory tests, it seems that some browsers (e.g. Firefox 3.5 and Safari 4) actually put these elements into HEAD when creating a document tree. This is not very surprising: browsers are known to tolerate and try to interpret all kinds of broken markup.

Having invalid markup is rarely a good idea. Non-standard handling by browsers might lead to various hard-to-pin rendering (and behavioral) inconsistencies. Instead of relying on browser guessing, it's best to follow a standard.

I don't know how search engines react to such tag soup, but I wouldn't risk experimenting to find out :) Perhaps they only parse HEAD tag for certain information and will skip your BODY-contained tags altogether. Or maybe they consider these to be some malicious gambling attempts and black-list pages containing such markup. Who knows.

The bottom line — avoid this whenever possible.