头和身体之间的脚本元素。 [HTML5] [英] Script Element Between Head and Body. [HTML5]

查看:115
本文介绍了头和身体之间的脚本元素。 [HTML5]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在使用W3C进行验证时,我收到了头部和身体之间的响应:
$ b


脚本元素。 [HTML5]


HTML5与常规XHTML验证相比具体如何?

HTML:
$ b

 < !doctype html> 
< html>
< head>
< meta charset =UTF-8>
< title>< / title>
< link href =services.css =stylesheettype =text / css>
< script>< / script>
< / head>
< body>

< div id =container>

< div id =header>
< / div>

< div id =body>
< / div>

< div id =footer>
< / div>

< / div>
< script>< / script>
< / body>
< / html>


解决方案

p>

您应该将它们放在头部或身体标签内。每次你都可以把它们放在身体的尽头。这是为了避免在下载脚本时阻止HTML呈现,从而提高网站响应速度。 w3.org


SCRIPT元素在脚本中放置一个脚本。此元素可能出现在HTML文档的HEAD或BODY中任何次数。



When validating with W3C, I received the response:

script element between head and body. [HTML5]

How is this specific to HTML5 versus regular XHTML validation?

HTML:

<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link href="services.css" rel="stylesheet" type="text/css">
<script></script>
</head>
<body>

<div id="container">

  <div id="header">
  </div>

  <div id="body">
  </div>

  <div id="footer">
  </div>

</div>
<script></script>
</body>
</html>

解决方案

You placed your scripts on an invalid spot.

You should place them within head or body tags. Every time you can, put them at the end of the body. This is to avoid blocking html rendering while dowloading scripts, improving site responsiveness.

From w3.org

The SCRIPT element places a script within a document. This element may appear any number of times in the HEAD or BODY of an HTML document.

这篇关于头和身体之间的脚本元素。 [HTML5]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆