Reputation: 9133
On the bootstrap CSS guide, there are numerous examples like this:
<div class="checkbox">
<label>
<input type="checkbox"> Check me out
</label>
</div>
Is it just me or is that input
tag not closed? It's definitely not a typo - they seemingly never close input tags. What would be the reason to consistently do this?
Upvotes: 0
Views: 165
Reputation: 4378
The input
tag is what is called a void element, and void elements do not require an end tag.
Here is a complete list of all void elements within HTML:
area
base
br
col
command
embed
hr
img
input
keygen
link meta
param
source
track
wbr
More about information void elements can be found here: Void Elements in HTML
Upvotes: 3
Reputation: 1
Actually, is a void element which means it's goal is not to contain text or whatever and it has a start tag but you shouldn't add an end tag.
This would not be W3C valid. On the other end, non-void elements MUST have an end tag.
(List of void elements : area, base, br, col, command, embed, hr, img, input, keygen, link, meta, param, source, track, wbr)
Upvotes: 0
Reputation: 23
According to w3schools.com, in HTML you do not need to close input tags at all.
But, in XHTML, the <input>
tag must be properly closed, like this <input/>
.
Upvotes: 0
Reputation: 161
The input tag doesn't need a closed tag.
Just in xHTML the tag must be closed properly: <input />
Upvotes: -1
Reputation: 943591
The <input>
element is defined as being a void element. The end tag for void elements is forbidden.
From the specification:
Tag omission in text/html: No end tag
Upvotes: 2