简体   繁体   English

标签头杂散末端

[英]Stray end of tag head

I am trying to learn to use framesets in HTML. 我正在尝试学习在HTML中使用框架集。 So, I started a little website with a friend. 所以,我和一个朋友开了一个小网站。 In following page (index.html) i receive an error on line 13: "Stray end of head tag". 在接下来的页面(index.html)中,我在第13行收到错误消息:“ head tag的杂散结尾​​”。 Why I get this error? 为什么会出现此错误?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> 
<html>
    <head>
        <title>Metal's page</title>

        <frameset cols = "20%,*" frameborder = "0">
            <frame src = "pages/menu.html">
            <frameset rows = "10%,*" frameborder = "0">
                <frame src = "pages/title.html">
                <frame name = "main" src = "index.html">
            </frameset>
        </frameset>
    </head> 

    <body bgcolor = red>
        <br/><br/><br/>
        <p>Hello, my name is Mihai, but one of my best friend call me "Metal". This is our web page. Enjoy!</p>
        <br/><br/>
    </body>
</html>

Website address: metalblog.besaba.com Thanks! 网站地址:metalblog.besaba.com谢谢!

You don't actually get that error message with that document, unless you manually tell the validator to ignore the DOCTYPE and use HTML 4.01 Frameset instead. 除非您手动告诉验证程序忽略DOCTYPE而是使用HTML 4.01 Frameset,否则实际上不会在该文档中收到该错误消息。

If you do that, or if you change the DOCTYPE to HTML 4.01 Frameset DOCTYPE, you get the error “ end tag for element "HEAD" which is not open” because the <frameset ...> implicitly closes the head element, so you are not allowed to close it again. 如果这样做,或者将DOCTYPE更改为HTML 4.01 Frameset DOCTYPE,则会收到错误消息“未打开的元素“ HEAD”的结束标记”,因为<frameset ...>隐式关闭了head元素,因此您不允许再次关闭它。

The reason for the implicit closing is that in a Frameset document , the frameset element appears instead of the body element, after the head element. 隐式关闭的原因是,在Frameset文档中frameset元素出现在head元素之后, 而不是 body元素。 There is no body element, since the contents of the frames are all that is displayed. 由于没有显示任何内容,因此没有body元素。

The following document validates: 以下文档验证:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" 
                      "http://www.w3.org/TR/html4/frameset.dtd">
<html>
    <head>
        <title>Metal's page</title>
    </head> 
        <frameset cols = "20%,*">
            <frame src = "pages/menu.html">
            <frameset rows = "10%,*">
                <frame src = "pages/title.html">
                <frame name = "main" src = "index.html">
            </frameset>
        </frameset>
</html>

Note that I have removed the frameborder attributes. 请注意,我已经删除了frameborder属性。 They are not valid in HTML 4.01 (or in any other HTML version). 它们在HTML 4.01(或任何其他HTML版本)中无效。 If you want to remove the borders between frames, you have to use that attribute and accept that the document is not valid. 如果要删除框架之间的边界,则必须使用该属性并接受该文档无效。 At least there was no way to remove the borders a few seasons ago, when frames were still used by some, though so last season; 至少在几个季节之前,尽管有些人仍在使用镜框,但上个赛季还是没有办法消除边界。 I don't think there has been any change in this respect. 我认为这方面没有任何变化。

It's probably because you have put your frame set inside of the head tags and not the body tags. 这可能是因为您将框架设置在head标签而不是body标签内。 All content should go in the body. 所有内容都应放在体内。

First of all, you are using a Strict DOCTYPE, which does not permit framesets. 首先,您使用的是严格的DOCTYPE,它不允许框架集。 Change to a frameset DOCTYPE. 更改为框架集DOCTYPE。 Run your markup through validator.w3.org until you are error free. 通过validator.w3.org运行标记,直到您没有错误为止。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM