Is it semantically valid to wrap all page's tags inside the form tag - ASP.net
-
31-05-2021 - |
문제
I am not new to ASP.net. Actually, I am not even learning it. But, I was recently evaluating some Web sites and saw that awful <form runat="server" ..>
that wraps the whole page and contains all other tags. The question: Is that valid HTML? It is 2012 and talks about semantic Web, accessible Web, etc. is hot. What do you think of it?
해결책
It is syntax-wise valid HTML. But I agree it's a bit 'outdated' a form and some hidden fields, etc. as ViewState. Also it can be quite cumbersome to work when you want to use more forms on the page (using JQuery f.i.).
Take a look at ASP.Net MVC, it solves the problem. You have full control over the HTML and does not need a form tag around the page. It does not use asp.net server controls.
다른 팁
The the HTML5 specification isn't too restrictive and allows most elements to nest within a form, but does state
The form element represents a collection of form-associated elements, some of which can represent editable values that can be submitted to a server for processing.
So it would seem to me that if the element isn't form-associated, it shouldn't really be there.