2

I use a HTML theme for my website. In this theme, there are form tags are shown as <form/>. Why does this theme use a slash after first form tag?

<div class="widget-body"> 
   <div class="widget-main"> 
      <form class="form-search" />
       <input type="text" class="input-medium search-query" /> 
       <button onclick="return false;" class="btn btn-purple btn-small"> 
          Search <i class="icon-search icon-on-right bigger-110"></i> 
       </button> 
      </form>
   </div> 
</div>
racecarjonathan
  • 1,210
  • 1
  • 11
  • 21
ali
  • 361
  • 4
  • 14
  • that should end the 'form' element – RedLaser Mar 23 '15 at 21:27
  • Chang `` to ` – Jonathan Mar 23 '15 at 21:39
  • See http://stackoverflow.com/questions/1946426/html-5-is-it-br-br-or-br, http://stackoverflow.com/questions/3558119/are-self-closing-tags-valid-in-html5 and http://stackoverflow.com/questions/7366344/do-we-still-need-end-slashes-in-html4. – Ilmari Karonen Mar 23 '15 at 22:30

3 Answers3

5

In XHTML syntax, an <example /> tag is equivalent to <example></example> tags.

So, your line of code <input type="text" class="input-medium search-query" />, is equivalent to <input type="text" class="input-medium search-query"></input>.

Community
  • 1
  • 1
racecarjonathan
  • 1,210
  • 1
  • 11
  • 21
  • tanx, do you mean input tag is outside form tag? – ali Mar 23 '15 at 21:30
  • No. Your `` tag is still within your `
    ` tag. It's just started and ended within one tag. Does that make sense? Instead of having a closing tag, you already closed it by using a forward slash.
    – racecarjonathan Mar 23 '15 at 21:34
0

after search i found in this link that

in HTML 5, <foo /> means <foo>, the start tag. It is not a "self-closing tag". Instead, certain elements are designated as having no end tag, for example <br>. These are collectively called void elements. The slash is just syntactic sugar for people who are addicted to XML. Using the slash in a non-void element tag is invalid, but browsers parse it as the start tag anyway, leading to a mismatch in end tags.

Community
  • 1
  • 1
ali
  • 361
  • 4
  • 14
  • ... except that in your example, there is a `` tag further down, so there is no mismatch in end tags, It's just a parse error, and the browser ignores the `/`, which just needs removing. – Alohci Mar 23 '15 at 21:43
  • @Alohci tnx but please see link – ali Mar 23 '15 at 21:50
  • Of all the things to revert on, uppercase tags and missing slashes were not something anyone should have an issue with. xhml 1.1 was very solid, but 5 should have at least been syntactically readable. – J. M. Becker Mar 15 '20 at 20:52
-1

You have a / after your form tag, remove it or it won't work ;)

Sileax
  • 49
  • 5