Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HTML : Getting warning - Invalid location of tag (input)

Tags:

html

xhtml

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.

like image 227
Bibhaw Avatar asked Jan 27 '11 10:01

Bibhaw


People also ask

Why is the input field in my form invalid?

For example, the input field is invalid if the required attribute is set and the field is empty (the required attribute specifies that the input field must be filled out before submitting the form). The numbers in the table specify the first browser version that fully supports the event attribute.

What is oninvalid event in HTML?

HTML oninvalid Event Attribute 1 Definition and Usage. The oninvalid event occurs when a submittable <input> element is invalid. ... 2 Browser Support. The numbers in the table specify the first browser version that fully supports the event attribute. 3 Syntax 4 Attribute Values 5 Technical Details 6 More Examples 7 Related Pages

Is it possible to use <span> and <input> in form tag?

The form tag may only contain block elements is XHTML Strict, so neither <span> nor <input> is valid. You can wrap it in a <div> though, then it is fine.


2 Answers

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.

like image 154
Quentin Avatar answered Sep 23 '22 01:09

Quentin


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

like image 31
keatch Avatar answered Sep 22 '22 01:09

keatch