is it a must to write input tag like <input /> instead of <input> </input> | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

is it a must to write input tag like <input /> instead of <input> </input>

what is the difference between <input /> and <input></input> tags

30th Jul 2018, 3:31 PM
SMH
SMH - avatar
6 Answers
+ 1
It must be written in <input /> only. Because it is language syntax and we must follow it in order to make it work. Hope this helps â˜șâ˜ș.
30th Jul 2018, 3:43 PM
Meet Mehta
Meet Mehta - avatar
+ 1
It is one of those tag which has no ending tag. Also modern editors supports <input>. No need of /.
30th Jul 2018, 3:45 PM
Meet Mehta
Meet Mehta - avatar
0
thank you
30th Jul 2018, 3:47 PM
SMH
SMH - avatar
0
<input type="radio" mane="gender" value="male">male</input> <input type="radio" mane="gender" value="male" />male The results are the same, please run this code and see.
30th Jul 2018, 3:55 PM
SMH
SMH - avatar
0
Thanks guys your so helpfull The W3C validator doesn't like self-closing tags (those that end with "/>") on non-voidelements. (Void elements are those that may not ever contain any content.) Are they still valid in HTML5? Some examples of accepted void elements: <br /> <img src="" /> <input type="text" name="username" /> Some examples of rejected non-void elements: <div id="myDiv" /> <span id="mySpan" /> <textarea id="someTextMessage" /> Note: the W3C validator actually accepts void self-closing tags: the author originally had a problem because of a simple typo (\> instead of />). However, self-closing tags are not 100% valid in HTML5 in general, and the answers elaborate on the issue of self-closing tags across various HTML flavors.
30th Jul 2018, 4:07 PM
SMH
SMH - avatar