What happens if the meta tags are present in the d

2019-01-07 17:33发布

I am working on a ASP application and the code, template and files are organized in a way that does not allow me to alter anything outside the body tag. So I am thinking about inserting the meta tags inside the body -- like this:

<!-- FEW ASP INCLUDES -->
<html>
    <head>
    <!-- FALLBACK TITLE AND DESCRIPTION -->
    <title>Default Title</title>
    <meta name="description" content="Default Description">
</head>
<body>
    <!-- SOME HTML MARKUP -->
    <div class="dynamic-content">
        <!-- InstanceBeginEditable name="dynamic-content" -->
        <!-- THIS IS WHERE I CAN WRITE ASP CODE -->
        <title><%= Page.Meta.GetTitle( yada, yada ) %></title>
        <meta name="description" content="<%= Page.Meta.GetDescription( yada, yada ) %>">
        <!-- InstanceEndEditable -->
    </div>
    <!-- SOME MORE HTML MARKUP -->
</body>
</html>

I am wondering how good it is to put meta tags inside the body of an HTML document. How does it affect:

  1. search engines
  2. browsers

8条回答
来,给爷笑一个
2楼-- · 2019-01-07 18:17

I would say you to use it. I found meta tags inside body on various webpages, and they are on one of top 10 searches (on google). It shows, at least to me, that searh engines don't mind if you have used this approach.

You must go ahead if there's no other way around.

查看更多
ら.Afraid
3楼-- · 2019-01-07 18:18

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.

查看更多
登录 后发表回答