HTML : Getting warning - Invalid location of tag (input)
I have开发者_高级运维 simple form and placed it inside the < div id="center">. It's working fine but still getting warning. why so ?
e.g. < div id="center">
<div id = "center">
<form action="test" method="post">
<input type="hidden" id="text1" name="texts"/> </input> --> getting warning
</form> </div>
Thanks in advance.
An <input>
element cannot be a child element of <form>
. A block element needs to go there.
You need something like form --> fieldset --> input
or form --> div --> input
.
You also have a self-closing <input />
followed by an end tag </input>
which doesn't have an open input to close.
You have already closed the input tag
<input type="hidden" id="text1" name="texts"/>
Written in this form is a self-closing tag. There is no need to close it in explicit form. Plus input must be inside a block container. Check the example here http://www.w3.org/TR/1999/REC-html401-19991224/interact/forms.html#h-17.4
by putting the <input type="text" ... />
within a <div>
block like this makes the error go away in eclipse or spring tool suite. following is a very basic example.
<div>
username:<input type="text" name="user" />
</div>
First of all, you seems to have mistakenly tried to close a single input tag twice.
<input type="hidden" id="text1" name="texts"/> </input>
.
Here, />
is a self closing tag,
and </input>
is closing the tag explicitly.
Please note that input
is a void element. And a void element can never have any contents under any circumstances. Although, void elements can have attributes.
So, its a good practice to avoid closing such tags explicitly.
Secondly, enclose the <input type="hidden" id="text1" name="texts"/>
within a block element like
<div>
<input type="hidden" id="text1" name="texts"/>
</div>
精彩评论