Reputation: 4048
Is there a good reason that a form tag should not exist in the head tag?
I was looking at this http://www.w3.org/html/wg/drafts/html/master/forms.html#the-form-element but I could not find anything related to this question.
This works for me:
<head runat="server">
<title></title>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
</form>
<link rel="stylesheet" href="http://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.2.min.js"></script>
<script src="http://ajax.aspnetcdn.com/ajax/jquery.mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>
</head>
Thanks in advance.
Upvotes: 0
Views: 1339
Reputation: 82976
If you look at http://software.hixie.ch/utilities/js/live-dom-viewer/saved/2014 in a browser other than IE (which has a very strange bug here), you will see that your form element is not in fact inside the head element. When the parser sees the <form>
tag, it automatically closes the <head>
element, creates the <body>
element and puts the <form>
element and all subsequent elements inside that <body>
element.
Because this behaviour is necessary for backward compatibility with existing web pages, the spec can't be changed to allow <form>
elements in head, even if there were a good use case for doing so.
Upvotes: 3
Reputation: 707238
HTML intended for display belongs in the <body>
tag.
There are some browsers that will still display some tags that are put in the <head>
tag, but that is not where it belongs and you are asking for interoperability problems if you put it there.
In the spec link that you referenced, it says that <form>
tags go where flow content
is expected. If you click on flow content
, it refers to elements used in the body of documents. The body is what is in the <body>
tag.
Upvotes: 1