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

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.

Leave a Comment