user3192948
user3192948

Reputation: 251

Having 2 <head> in 1 page

I have 2 <head> tags in one web page. Reason is that I used to have the header, the content and the footer views loaded separately, so I left 1 <head> in the header view and another in the content view.

What's the effect of this? If it's not compliant with html standard, then should I get rid of all extra <head> and only leave 1 in 1 page?

Upvotes: 1

Views: 148

Answers (2)

guest
guest

Reputation: 6698

Here's specifically what happens, when an HTML5-compliant browser parses a document with two head elements:

  • gets to the first </head> tag: The "after head" insertion mode
  • encounters the second <head> tag: "Parse error. Ignore the token."
  • encounters some other tags, e.g. <meta>: Parse error, but it basically adds the tag to the previous head element.
  • encounters second </head> tag: "Parse error. Ignore the token."

So what does this mean? It is a parse error to have multiple heads. However, the standard is clear on what should happen in this case. It does the "right" thing and merges the them.

I should also point out that <head></head> tags are optional. You can leave them out and have no parse errors.

Upvotes: 0

bjb568
bjb568

Reputation: 11498

This is what HTML looks like:

<!DOCTYPE html>
<html>
    <head><!-- The *required* head -->
        <title>The *required* title</title>
    </head>
    <body><!-- The *required* body -->
        Stuff
    </body>
</html>

Don't do anything besides that - that includes using two head tags. I think what you want is iframes.

Upvotes: 1

Related Questions