Why doesn't this form validate ?

Discussion in 'HTML' started by Arjen, Oct 13, 2006.

  1. Arjen

    Arjen Guest

    Hi, this piece of html doesn;t validate. That w3c validator sais
    something about block elements in inline elements. As I understand it
    <p><form></form></p> is valid or am I wrong ?

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>test</title>
    </head>
    <body>
    <div id = "testx">
    <p>
    text<br />
    <form action="index.php" method="post">
    veld:<br />
    <input type="text" name="field" id="field"><br \>
    <input type="submit" id="submitid" value="Submit" />
    </form>
    </p>
    </div>
    </body>
    </html>
    Arjen, Oct 13, 2006
    #1
    1. Advertising

  2. Arjen

    Ed Jay Guest

    Arjen scribed:

    >Hi, this piece of html doesn;t validate. That w3c validator sais
    >something about block elements in inline elements. As I understand it
    ><p><form></form></p> is valid or am I wrong ?
    >
    ><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    >"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    ><html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    ><head>
    ><title>test</title>
    ></head>
    ><body>
    ><div id = "testx">
    ><p>
    >text<br />


    Is this supposed to be />
    ><form action="index.php" method="post">
    >veld:<br />
    ><input type="text" name="field" id="field"><br \>

    or like this \>?

    ><input type="submit" id="submitid" value="Submit" />
    ></form>
    ></p>
    ></div>
    ></body>
    ></html>

    --
    Ed Jay (remove 'M' to respond by email)
    Ed Jay, Oct 14, 2006
    #2
    1. Advertising

  3. Arjen

    Arjen Guest

    Ed Jay wrote:
    > Arjen scribed:


    > Is this supposed to be />
    > or like this \>?


    Hi Ed,

    Hmm that's a difficult one !
    I guess again no points for typing :)

    I dont think that's the problem. I just slimmed down the page to where
    the errors began and made a typo.

    It seems I cant put a form element into a div. This is a problem for me
    since the divs are assigned in my framework and not specifically in
    order of creation. That is sorted out later. So I have no good way of
    nesting the forms as I dont know where and when they will turn up in
    advance.

    for example
    $htlml->addhtml('x','y');
    $htlml->addhtml('a','b');
    $htlml->addhtml('z','y');

    might output

    <div id="a">
    b
    </div>
    <div id="y">
    x
    z
    </div>

    any ideas ???

    Arjen

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <title>test</title>
    </head>
    <body>
    <div id = "testx">
    <form action="index.php" method="post">
    <input type="text" name="field" id="field">
    </form>
    </div>
    </body>
    </html>

    wont validate either
    Arjen, Oct 14, 2006
    #3
  4. Arjen

    Andy Dingley Guest

    Arjen wrote:

    > Hi, this piece of html doesn;t validate. That w3c validator sais
    > something about block elements in inline elements. As I understand it
    > <p><form></form></p> is valid or am I wrong ?


    Invalid.

    There's no such thing as a simple "block element" (I've made a couple
    of postings on this in the last couple of weeks). There are elements
    that are _members_of_ block, and elements that can _contain_ block. One
    doesn't imply the other, and <p> is the obvious example. <p> acts like
    block itself, but it can only contain inline.
    Andy Dingley, Oct 14, 2006
    #4
  5. Arjen

    Arjen Guest

    Andy Dingley wrote:
    > Arjen wrote:
    >
    >> Hi, this piece of html doesn;t validate. That w3c validator sais
    >> something about block elements in inline elements. As I understand it
    >> <p><form></form></p> is valid or am I wrong ?

    >
    > Invalid.
    >
    > There's no such thing as a simple "block element" (I've made a couple
    > of postings on this in the last couple of weeks). There are elements
    > that are _members_of_ block, and elements that can _contain_ block. One
    > doesn't imply the other, and <p> is the obvious example. <p> acts like
    > block itself, but it can only contain inline.


    Hi Andy,

    Thx for your reply.

    I have no idea what you mean. I didnt even know there was such a thing
    as block and inline elements till a few hours ago :)

    You are referring to your earlies posts. Ill loop them up first thing in
    the morning. (it's 02:00 now and the screen is spinning) and ill try to
    figure it out.

    Thx

    Arjen
    Arjen, Oct 14, 2006
    #5
  6. Arjen

    cwdjrxyz Guest

    Arjen wrote:
    > Hi, this piece of html doesn;t validate. That w3c validator sais
    > something about block elements in inline elements. As I understand it
    > <p><form></form></p> is valid or am I wrong ?
    >
    > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    > <head>
    > <title>test</title>
    > </head>
    > <body>
    > <div id = "testx">
    > <p>
    > text<br />
    > <form action="index.php" method="post">
    > veld:<br />
    > <input type="text" name="field" id="field"><br \>
    > <input type="submit" id="submitid" value="Submit" />
    > </form>
    > </p>
    > </div>
    > </body>
    > </html>


    I will leave it to others to explain in detail why your form had
    validation problems - there were several error messages in fact.
    However see http://www.cwdjr.info/test/formtest.html for a modified
    version of your test page that does validate at W3C as xhtml 1.0
    strict. You may need to reformat it a bit to display exactly as you
    wish on the page. Note that the validator is much more strict for a
    xhtml page than a html 4.01 strict page, and you often can get away
    with much more in html without validator error messages. Are you
    actually planning to serve the page as true xhtml, with your server set
    up with perhaps .xhtml associated with the mime type
    application/xhtml+xml ? If you just serve it as usual with the html
    extension, your page just gets served as text/html normal html despite
    the xhtml Doctype. But if you do serve as true xhtml with the mentioned
    mime type, IE6 will not view true xhtml. This would require a separate
    html 4.01 strict page for IE6 and a convenient method for selecting it
    when needed. This would require some server side code such as php or
    something else to modify the code or redirect to another page when an
    html page is needed for IE6 and some early browsers.

    Note that my example page is being served as .html because that is how
    I assumed you wished to do it because of the your extension .html
    rather than .xtml or .xml. Doing it this way, you might as well write
    the page as html 4.01 strict because the page is only going to be
    served as html - not xhtml or xml - anyway.
    cwdjrxyz, Oct 14, 2006
    #6
  7. Arjen

    Ed Seedhouse Guest

    On Sat, 14 Oct 2006 00:51:19 +0200, Arjen <> wrote:

    > As I understand it
    ><p><form></form></p> is valid or am I wrong ?


    You are wrong. <p> cannot contain other block elements.
    Ed Seedhouse, Oct 14, 2006
    #7
  8. Arjen

    Arjen Guest

    > I will leave it to others to explain in detail why your form had
    > validation problems - there were several error messages in fact.
    > However see http://www.cwdjr.info/test/formtest.html for a modified
    > version of your test page that does validate at W3C as xhtml 1.0
    > strict.


    Cool thx ! <div><form><p>stuf</p></form</div> :)


    > You may need to reformat it a bit to display exactly as you
    > wish on the page. Note that the validator is much more strict for a
    > xhtml page than a html 4.01 strict page, and you often can get away
    > with much more in html without validator error messages. Are you
    > actually planning to serve the page as true xhtml, with your server set
    > up with perhaps .xhtml associated with the mime type
    > application/xhtml+xml ?


    Actually all files will have the php extention. Im letting a friend do
    the server settings so I really dont know about the server associated
    mime type. The framework generates most stuf automatically in xhtml
    strict. That's why I try to use it. I guess I can send the output buffer
    thru another template wich will output html 4.01

    > Note that my example page is being served as .html because that is how
    > I assumed you wished to do it because of the your extension .html
    > rather than .xtml or .xml. Doing it this way, you might as well write
    > the page as html 4.01 strict because the page is only going to be
    > served as html - not xhtml or xml - anyway.


    I dont remember saying I used th html extention. Did I miss something ?

    Anyway im really glad with your help !

    Thx

    Arjen
    Arjen, Oct 14, 2006
    #8
  9. Arjen

    Andy Dingley Guest

    Arjen wrote:

    > I have no idea what you mean. I didnt even know there was such a thing
    > as block and inline elements till a few hours ago :)


    In that case, abandon the XHTML and use HTML 4.01 Strict instead.

    XHTML has almost nothing to offer, and it's hard to use it correctly.
    Best avoided unless you know you need it, and why.
    Andy Dingley, Oct 14, 2006
    #9
  10. Arjen

    Arjen Guest

    Andy Dingley wrote:
    > Arjen wrote:
    >
    >> I have no idea what you mean. I didnt even know there was such a thing
    >> as block and inline elements till a few hours ago :)

    >
    > In that case, abandon the XHTML and use HTML 4.01 Strict instead.
    >
    > XHTML has almost nothing to offer, and it's hard to use it correctly.
    > Best avoided unless you know you need it, and why.


    I'd like to but the framework generates XHTML. So im stuck with it and
    i'd better learn fast :) I thought I had figured out most differences
    between HTML 4 AND XHTML 1 but I guess I didn't really.

    As it turns out I know the difference between block and inline elements
    (sorta) but it was implicit knowledge. Ill figure it out :)

    Thx for your reply and I read your posts wich were interesting

    Arjen
    Arjen, Oct 14, 2006
    #10
  11. Arjen

    Andy Dingley Guest

    Arjen wrote:

    > I'd like to but the framework generates XHTML.


    Bitter experience suggests that the framework will then be broken and
    will grossly mis-use XHTML too! There's no reason it should force
    the output to be XHTML, even if it's used internally by the CMS. There
    are very good reasons why any competent framework must be able to offer
    HTML as an output choice.

    If you do use XHTML (and you certainly can), then you're force into
    using Appendix C and serving is as text/html.
    Andy Dingley, Oct 14, 2006
    #11
  12. Arjen

    cwdjrxyz Guest

    Arjen wrote:
    > > I will leave it to others to explain in detail why your form had
    > > validation problems - there were several error messages in fact.
    > > However see http://www.cwdjr.info/test/formtest.html for a modified
    > > version of your test page that does validate at W3C as xhtml 1.0
    > > strict.

    >
    > Cool thx ! <div><form><p>stuf</p></form</div> :)
    >
    >
    > > You may need to reformat it a bit to display exactly as you
    > > wish on the page. Note that the validator is much more strict for a
    > > xhtml page than a html 4.01 strict page, and you often can get away
    > > with much more in html without validator error messages. Are you
    > > actually planning to serve the page as true xhtml, with your server set
    > > up with perhaps .xhtml associated with the mime type
    > > application/xhtml+xml ?

    >
    > Actually all files will have the php extention. Im letting a friend do
    > the server settings so I really dont know about the server associated
    > mime type. The framework generates most stuf automatically in xhtml
    > strict. That's why I try to use it. I guess I can send the output buffer
    > thru another template wich will output html 4.01


    To tell how a page is servered, go to the W3C validator and select the
    extended interface. Then check the "show source" and "verbose output"
    boxes. Enter the page URL and validate. Near the top of the page you
    will see Content-type. For an html page you get text/html; for xhtml
    you get application/xhtml+xml; for an xml page you get application/xml.
    This is how the page is actually served. Now test the page I gave you
    in a previous post served as .html. Next test the page
    http://www.cwdjr.info/test/formtestXML.xml that is served as xml by
    setting the mime type for application/xml for the extension .xml on the
    server. Next test the page http://www.cwdjr.info/test/formtestX.xhtml
    that is served by setting the mime type for application/xhtml+xml on
    the server to correspond to the extension .xhtml.

    Now try the mentioned pages on recent Mozilla family browsers(Firefox,
    Mozilla, Netscape, Mozilla) and Opera. All 3 pages work. Then try the 3
    pages on IE6. The page works only when served as .html. The pages
    served as .xhtml or .xml can not be handled. In this case you just get
    the source code displayed on IE6. In other cases you get an error
    message on IE6.

    A page with the .php extension will get served as usually one of the 3
    types mentioned above and the content-type on extended interface
    validation at the W3C will tell you how the php page is being served.

    If a page views properly on IE6, it is not being served as true xhtml
    or xml.
    cwdjrxyz, Oct 14, 2006
    #12
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Rinus Luijmes
    Replies:
    1
    Views:
    1,154
    TopoGrafix
    Aug 3, 2005
  2. Mr. SweatyFinger

    why why why why why

    Mr. SweatyFinger, Nov 28, 2006, in forum: ASP .Net
    Replies:
    4
    Views:
    878
    Mark Rae
    Dec 21, 2006
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    1,836
    Smokey Grindel
    Dec 2, 2006
  4. KathyB
    Replies:
    3
    Views:
    96
    George M Jempty
    Sep 10, 2003
  5. Replies:
    1
    Views:
    690
    Randell D.
    Mar 17, 2005
Loading...

Share This Page