ali
ali

Reputation: 431

Use slash after HTML tag

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>

Upvotes: 3

Views: 8993

Answers (3)

racecarjonathan
racecarjonathan

Reputation: 1234

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>.

Upvotes: 9

Sileax
Sileax

Reputation: 69

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

Upvotes: 0

ali
ali

Reputation: 431

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.

Upvotes: 3

Related Questions