Mihail Feraru
Mihail Feraru

Reputation: 173

Stray end of tag head

I am trying to learn to use framesets in 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". 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!

Upvotes: 0

Views: 965

Answers (3)

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201558

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.

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.

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. There is no body element, since the contents of the frames are all that is displayed.

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. They are not valid in HTML 4.01 (or in any other HTML version). 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.

Upvotes: 1

mr_plum
mr_plum

Reputation: 2437

First of all, you are using a Strict DOCTYPE, which does not permit framesets. Change to a frameset DOCTYPE. Run your markup through validator.w3.org until you are error free.

Upvotes: 0

codepuncher
codepuncher

Reputation: 44

It's probably because you have put your frame set inside of the head tags and not the body tags. All content should go in the body.

Upvotes: 0

Related Questions