document type does not allow element "input" here

S

showandbeshown

Hi,

I try to validate an xhtml document. I got the following message:
Line 52, Column 109: document type does not allow element "input"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag.

I cannot understand the reason of that because the line 52 DOES NOT
contain the element "input". Well, I have this element 2 lines bellow,
but it IS included into the block-level element <div>.

Can anybody help me?

The source can be found here:
http://www.showandbeshown.com/create_link.php
 
J

Jonathan N. Little

Hi,

I try to validate an xhtml document. I got the following message:
Line 52, Column 109: document type does not allow element "input"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag.

I cannot understand the reason of that because the line 52 DOES NOT
contain the element "input". Well, I have this element 2 lines bellow,
but it IS included into the block-level element <div>.

Can anybody help me?

The source can be found here:
http://www.showandbeshown.com/create_link.php

Put your hidden input inside the div and your problem will go away.
 
Z

zach

Jonathan said:
Put your hidden input inside the div and your problem will go away.

The problem has nothing to do with a div, the problem is you have:

<input type="text" name="searchbox" size="19" maxlength="30" ></input>

That isn't the proper way to close an input element. You need to remove
the </input and but a backslash at the end of the main input element
like this:

<input type="text" name="searchbox" size="19" maxlength="30" />
 
I

I V

The problem has nothing to do with a div, the problem is you have:

<input type="text" name="searchbox" size="19" maxlength="30" ></input>

That isn't the proper way to close an input element. You need to remove

No, that's not right. The OP's code is exactly equivalent to the code you
suggest - both are equally valid ways of writing an empty element. Besides
which, the problem isn't with the text input, it's with the hidden input
two lines above.

To the OP: The hidden input doesn't show up when I view source from the
browser, but does show up in the validator's "view source" or if I use
wget the access your URL. Have a look at:

http://validator.w3.org/check?uri=h...atically)&doctype=Inline&ss=1&group=0#line-52

I suspect it only shows up when you are accessing the URL without cookies,
and is being added by PHP (because the input is called PHPSESSID). I'm not
sure, without seeing the PHP code how you would persuade PHP to put the
input inside the DIV. You might want to post your source code to a PHP
group.
 
T

Toby A Inkster

I said:
I suspect it only shows up when you are accessing the URL without
cookies, and is being added by PHP (because the input is called
PHPSESSID).

Yep, this is PHP's automatic session variable thingy.

Normally session variable is passed using cookies, but PHP has an option
that allows it to be passed by automatically rewriting forms and links.

If you do not care about supporting User-Agents that don't allow cookies,
then you can disable this rewriting be enabling the
session.use_only_cookies option in your php.ini file.

Or, if you were to use <fieldset> elements instead of <div>, then PHP is
smart enough to put its hidden input inside the <fieldset> instead of
inside the form.

--
Toby A Inkster BSc (Hons) ARCS
[Geek of HTML/SQL/Perl/PHP/Python/Apache/Linux]
[OS: Linux 2.6.17.14-mm-desktop-9mdvsmp, up 1 day, 21:52.]

Sharing Music with Apple iTunes
http://tobyinkster.co.uk/blog/2007/11/28/itunes-sharing/
 
J

Jukka K. Korpela

Scripsit I V:
The OP's code is exactly equivalent to the code
you suggest - both are equally valid ways of writing an empty
element.

This is not essential to the problem at hand, but it is relevant
otherwise. The statement you make above is correct but grossly
misleading.

<input></input> and <input/> are equally _valid_ in XHTML but only one
of them is _correct_. Anyone who doesn't understand this should not use
XHTML, especially since he has probably missed most of the (in)famous
Appendix C.

(If you don't know what "Appendix C" refers in contexts like this, you
surely shouldn't be using XHTML.)
 
Z

zach

I said:
No, that's not right. The OP's code is exactly equivalent to the code you
suggest - both are equally valid ways of writing an empty element. Besides
which, the problem isn't with the text input, it's with the hidden input
two lines above.

To the OP: The hidden input doesn't show up when I view source from the
browser, but does show up in the validator's "view source" or if I use
wget the access your URL. Have a look at:

http://validator.w3.org/check?uri=h...atically)&doctype=Inline&ss=1&group=0#line-52

I suspect it only shows up when you are accessing the URL without cookies,
and is being added by PHP (because the input is called PHPSESSID). I'm not
sure, without seeing the PHP code how you would persuade PHP to put the
input inside the DIV. You might want to post your source code to a PHP
group.

By changing the code I suggested it will validate. There is nothing
wrong with the hidden input. Go back and re-read my suggestion and then
read the w3c documentation on XHTML 1.0 STRICT

http://www.w3.org/TR/xhtml1/Overview.html
 
Z

zach

I said:
No, that's not right. The OP's code is exactly equivalent to the code you
suggest - both are equally valid ways of writing an empty element. Besides
which, the problem isn't with the text input, it's with the hidden input
two lines above.

To the OP: The hidden input doesn't show up when I view source from the
browser, but does show up in the validator's "view source" or if I use
wget the access your URL. Have a look at:

http://validator.w3.org/check?uri=h...atically)&doctype=Inline&ss=1&group=0#line-52

I suspect it only shows up when you are accessing the URL without cookies,
and is being added by PHP (because the input is called PHPSESSID). I'm not
sure, without seeing the PHP code how you would persuade PHP to put the
input inside the DIV. You might want to post your source code to a PHP
group.
I apologize, I was incorrect, my reader was cutting off some of your
reply so I did not see everything you suggested.
 
S

showandbeshown

I have again the same error-message (with another code). In this code
I used <input /> syntax, I have hidden input in the forms, and I have
included form elements into <div> tags. But it does not help! Does
anybody have any idea what is my problem?
 
R

rf

I have again the same error-message (with another code). In this code
I used <input /> syntax, I have hidden input in the forms, and I have
included form elements into <div> tags. But it does not help! Does
anybody have any idea what is my problem?

Didn't you understand the previous answer to this given to you by Jonathan?

"Put your hidden input inside the div and your problem will go away."

You have <form...><input...><div> ...

What you need is <form...><div><input...>

Forms may not contain inline elements as direct children. Input is an inline
element.
 
R

rf


Ignore my other post. I was looking at the URL you had posted previously,
silly me :)

Now, which of the 23 errors are you referring to? I see no "does not allow"
error?

Why are you using XHTML anyway. The most used browser out there does not
understand XHTML which means you must serve it as text/html which means
*every* browser is error correcting it to HTML. Why not just use HTML
anyway?
 
S

showandbeshown

Didn't you understand the previous answer to this given to you by Jonathan?

"Put your hidden input inside the div and your problem will go away."

You have <form...><input...><div> ...

What you need is <form...><div><input...>

Forms may not contain inline elements as direct children. Input is an inline
element.

Hi Richard,

But I do have <form...><div><input...> sequence. In my code the <div>
tags go immediately after the <form> tags.
 
S

showandbeshown

Ignore my other post. I was looking at the URL you had posted previously,
silly me :)

Now, which of the 23 errors are you referring to? I see no "does not allow"
error?
Strange, I have 26 errors and the first of them is:
Line 52, Column 160: document type does not allow element "input"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag.
....="4bf822382c741097d6b28e594ee4cdfa" /> said:
Why are you using XHTML anyway. The most used browser out there does not
understand XHTML which means you must serve it as text/html which means
*every* browser is error correcting it to HTML. Why not just use HTML
anyway?
I tried to write this page in html 4.01 strict and I had some problem
which forced me to go back to xhtml... But I forgot what was my
problem. Sorry. It is really stupid. :) I think, I will try to
rewrite the code in html again and if I meat this problem again I will
let you know.
 
J

Jonathan N. Little

Strange, I have 26 errors and the first of them is:
Line 52, Column 160: document type does not allow element "input"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag.
...="4bf822382c741097d6b28e594ee4cdfa" /><div>

<form enctype="multipart/form-data" action="tmp3.php"
method="post"><input type="hidden" name="PHPSESSID"
value="3a04eed62bd8689f1377fdc9164dbd4a" /><div>

NOTE: PHPSESSID hidden *before* <div>? This is inserted because of the
way you have your PHP sessions set up, Toby explained it to you earlier
in the thread.

http://message-id.net/<[email protected]>
I tried to write this page in html 4.01 strict and I had some problem
which forced me to go back to xhtml... But I forgot what was my
problem. Sorry. It is really stupid. :) I think, I will try to
rewrite the code in html again and if I meat this problem again I will
let you know.

No reason to use XHTML. Stick with HTML unless you have some real reason
to do otherwise.
 
R

rf

Strange, I have 26 errors and the first of them is:
Line 52, Column 160: document type does not allow element "input"
here; missing one of "p", "h1", "h2", "h3", "h4", "h5", "h6", "div",
"pre", "address", "fieldset", "ins", "del" start-tag.

I tried to write this page in html 4.01 strict and I had some problem
which forced me to go back to xhtml... But I forgot what was my
problem. Sorry. It is really stupid. :) I think, I will try to
rewrite the code in html again and if I meat this problem again I will
let you know.

Re-write? Not really. All you have to do is feed it to the validator and
remove the spurious / at the end of some tags.
 
Joined
Sep 20, 2011
Messages
1
Reaction score
0
People like you make me sick!

@Jukka K. Korpela: Sorry, but whenever I come across dumb nerd comments like this it just makes me wanna puke! Why don't you just leave all the "I'm so clever and you're so noob"-**** and HELP THE GUY WHO ASKED THE QUESTION. Goddamit......really!
 
Last edited:
Joined
Sep 28, 2011
Messages
1
Reaction score
0
Can no longer see the code but this sort of validation error in forms usually comes from not using a fieldset to contain the inline elements. Wrap the inputs and submit in a fieldset if you have not done so already and see what happens :)

ps.Totally agree with daze20's view on Jukka's earlier post, totally uncalled for snobbishness, more annoying than the "google is your friend" type of comment. I find half my answers in forums that have that comment posted somewhere within them. If you know the answer just write it down! If not or you dont want to then just dont write anything!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,056
Messages
2,570,443
Members
47,089
Latest member
Bobby2025b

Latest Threads

Top