<script> tag position before <html> tag

点点圈 提交于 2019-12-25 02:19:00

问题


Can a <script> tag between <!DOCTYPE html> and <html> be valid?

The reason I ask is I found the code I've described above. Can it be valid under any circumstances?


回答1:


No. <html> is the root (or document) element of an HTML document; it must be the only root-level element in an HTML document (it cannot have any siblings). Further, HTML can only contain <head> and <body> (specifically one of each), meaning that any other tags (e.g. <script> must be descendants of <head> or <body>.




回答2:


I don't think so. If you want check. Use this validator: http://validator.w3.org/#validate_by_input+with_options



来源:https://stackoverflow.com/questions/22794684/script-tag-position-before-html-tag

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!