Reputation: 431
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
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
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