<form> tag is self-closing before input fields .. (HAML generator used)

The form is inside a table, enclosing a <tr>

  = form_tag admins_backoffice_dashboards_path, :remote =>"true" do              %tr.search                  %th= link_to t(:clear), "#", :id => :clearFilter            %th= select_tag :role, options_from_collection_for_select(Role.global, :id, :name, :selected => @role_id )      %th= text_field_tag :email, nil, :value => @email      %th= submit_tag t(:search).capitalize

the generated html code is :

<table class="table table-condensed">    <form method="post" data-remote="true" action="/en/backoffice/ dashboards/admins" accept-charset="UTF-8"></form>          <tr class="search">                 <th><a id="clearFilter" href="#">Clear</a></th>                     <th>       <select name="role" id="role" class="input-medium list">           </option><option value="2">superadmin</option>                              <option value="3">manager</option>                               <option value="4">employee</option>            </select>                    </th>                    <th><input type="text" name="email" id="email"></

                   <th><input type="submit" value="Search" name="commit"></th>          </tr> </table>

what could be wrong ..? is it so obvious ? thanks for feedback

That's not legal markup. Either wrap the form around the entire table or put it completely inside a cell.

Thanks , I had that feeling... I'll test it by tomorrow ... is there any links related to this being illegal ? just for my notetaker pad ...

The HTML 4.01 DTDs are what I usually refer to when in doubt:

  <http://www.w3.org/TR/REC-html40/sgml/dtd.html&gt;

I'm under the impression HTML 5 doesn't use DTDs but I'm trying to leave markup to others as much as possible these days :slight_smile:

HTH!

Thanks , I had that feeling... I'll test it by tomorrow ... is there any links related to this being illegal ? just for my notetaker pad ...

If ever you have any markup and you just want to check whether it is legal you can paste it into the w3c html validator and it will check it for you. In fact any time a page is misbehaving in a strange way it is a good idea to check the html for validity, and before any page is made public it should be checked. Even if a page looks ok there may still be invalid html there which can make it perform differently on different browsers.

Colin

Since I didn't see the rest of this I'll just comment as if it's future-proofed markup. In HTML5 <form /> simply means <form>, it's a grey area, it's not allowed but it's parsed and even has parsing rules but it means <form> so you will end up with a parsing error eventually possibly. It has parsing rules because of XML and XHTML. It does not mean <form></form> like most people assume.

While I agree with Colin that you should check with the W3 validator I also think that you should take any of the HTML5 markup validations with a grain of salt and refer to the spec HTML Standard because there are grey areas that will get you later.

Thanks , I had that feeling... I'll test it by tomorrow ... is there any links related to this being illegal ? just for my notetaker pad ...

If ever you have any markup and you just want to check whether it is legal you can paste it into the w3c html validator and it will check it for you. In fact any time a page is misbehaving in a strange way it is a good idea to check the html for validity, and before any page is made public it should be checked. Even if a page looks ok there may still be invalid html there which can make it perform differently on different browsers.

Since I didn't see the rest of this I'll just comment as if it's future-proofed markup. In HTML5 <form /> simply means <form>, it's a grey area, it's not allowed but it's parsed and even has parsing rules but it means <form> so you will end up with a parsing error eventually possibly. It has parsing rules because of XML and XHTML. It does not mean <form></form> like most people assume.

I don't understand what you mean by "it's not allowed". If it parses without an error then how can it not be allowed? Or are you pointing out that the spec is inconsistent?

Why would one want to do <form /> anyway?

Colin

The form is inside a table, enclosing a

That’s not legal markup. Either wrap the form around the entire table

or put it completely inside a cell.

Although haml doesn’t know that - it will quite happily generate markup that is invalid in that way. My money would be the the tr is indented with something that looks like a space to a human, but not to haml (maybe a tab or one of the funky unicode spacing characters)

Fred

That's exactly what I mean by a grey area, it's one of those things that you're not supposed to do, it's "not allowed" but they allow it to parse and pass because it's so popular and because it was so widely used prior to HTML5 via XHTML from XML, that and it's converted to <tag> which is perfectly valid in some circumstance. I don't quite remember if there was intent to make it fully illegal but right now it's a grey area in that it parses but you are not supposed to do it because it's "not allowed" in HTML5.

TL;DR

<form /> -> <form> = valid but could lead to parse error because of nesting issues. <form /> is not legal in HTML5 but parsed and "passed" because of syntactic sugar and XML.