在 HTML </head> 之间放置代码或内容是否合适?和<身体>标签

2022-01-11 00:00:00 header standards head html markup

是否可以将 HTML 代码放在头部区域的结尾和正文区域的开头之间.我以前在各个站点上都这样做过,没有任何问题,但是,我想知道这是否有任何向后兼容性问题,以及这是否常见或良好的做法.例如:

Is it okay to place HTML code between the ending of the head area and before the beginning of the body area. I have done this before, on various sites without any problems, however, I would like to know whether this has any backwards compatibility issues, and also whether this is common, or good practice. For example:

</head>

   <div id="header">

       <h1>Heading</h1>

       Code & Content...

   </div><!-- #header -->

 <body>

    Code & Content...

 </body>

推荐答案

不行,不行.页面的所有内容都应该放在 <body> 中.检查 HTML 规范.浏览器真的很宽容,但即使它有效,你也不应该这样做.

No, is not okay. All the content of the page should go inside <body>. Check the HTML specification. Browsers are really forgiving, but even if it works you shouldn't do it.

相关文章