xhtml and input tag outside form

Discussion in 'HTML' started by Zone, Jan 22, 2008.

  1. Zone

    Zone Guest

    Hello,

    I have tried to understand why input field is valid outside form tag.
    I seems to work outside form if e.g. input tag is inserted inside div tag.

    I tried to read http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
    but didn't find any solution.

    Can anyone clearify were input is accepted if it's not inside form?

    Cheers,
     
    Zone, Jan 22, 2008
    #1
    1. Advertising

  2. Zone wrote:

    > I have tried to understand why input field is valid outside form tag. I
    > seems to work outside form if e.g. input tag is inserted inside div tag.


    <input> (and <textarea>, <button>) is an inline element, like <span> or
    <em>, so can be used in any context where inline content is allowed, which
    is virtually everywhere.

    Why? Because otherwise <input> couldn't be contained in, for example, a
    paragraph, even if that paragraph was itself within a 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 23 days, 20:54.]

    CSS to HTML Compiler
    http://tobyinkster.co.uk/blog/2008/01/22/css-compile/
     
    Toby A Inkster, Jan 23, 2008
    #2
    1. Advertising

  3. Zone wrote:
    > Hello,
    >
    > I have tried to understand why input field is valid outside form tag.
    > I seems to work outside form if e.g. input tag is inserted inside div tag.
    >
    > I tried to read http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
    > but didn't find any solution.
    >
    > Can anyone clearify were input is accepted if it's not inside form?


    Besides what Toby said about why it's valid (which is correct) it's also
    reasonable if you're using controls to receive user input that is going
    to be used on the client side rather than for submitting to a server. An
    example would be a client-side measurement or currency converter coded
    in Javascript. Functionally speaking there's no need for a form since
    nothing is being submitted to the server.
     
    Harlan Messinger, Jan 23, 2008
    #3
  4. Scripsit Toby A Inkster:

    > <input> (and <textarea>, <button>) is an inline element, like <span>
    > or <em>, so can be used in any context where inline content is
    > allowed, which is virtually everywhere.


    Well, not quite everywhere. Not in the document's head, and in Strict,
    not in its body either. :)

    (Just kidding. But really, in Strict versions, <input> is not allowed
    _directly_ inside <body>, i.e. as a child element, only indirectly
    inside a block-like container.)

    > Why? Because otherwise <input> couldn't be contained in, for example,
    > a paragraph, even if that paragraph was itself within a form,


    No, the syntax rules _could_ have been written so that <input> is only
    allowed inside a <form> directly or indirectly. That would be fairly
    simple in classic HTML, nominally based on SGML (which has exclusion
    exceptions). It would not be possible at the DTD level in XHTML, based
    on the toy version of SGML called XML, but it could have been added as
    requirement in prose, just as XHTML 1.0 prosaically forbids an <a>
    element inside an <a> element even though its DTD syntax allows it.

    The real reason is that people who decided on HTML specs wanted to allow
    lone <input> elements for use with client-side scripting.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Jan 23, 2008
    #4
  5. Zone

    Zone Guest

    "Jukka K. Korpela" <> wrote in message
    news:1jFlj.285172$...
    > Scripsit Toby A Inkster:
    >
    >> <input> (and <textarea>, <button>) is an inline element, like <span>
    >> or <em>, so can be used in any context where inline content is
    >> allowed, which is virtually everywhere.

    >
    > Well, not quite everywhere. Not in the document's head, and in Strict, not
    > in its body either. :)
    >
    > (Just kidding. But really, in Strict versions, <input> is not allowed
    > _directly_ inside <body>, i.e. as a child element, only indirectly inside
    > a block-like container.)
    >
    >> Why? Because otherwise <input> couldn't be contained in, for example,
    >> a paragraph, even if that paragraph was itself within a form,

    >
    > No, the syntax rules _could_ have been written so that <input> is only
    > allowed inside a <form> directly or indirectly. That would be fairly
    > simple in classic HTML, nominally based on SGML (which has exclusion
    > exceptions). It would not be possible at the DTD level in XHTML, based on
    > the toy version of SGML called XML, but it could have been added as
    > requirement in prose, just as XHTML 1.0 prosaically forbids an <a> element
    > inside an <a> element even though its DTD syntax allows it.
    >
    > The real reason is that people who decided on HTML specs wanted to allow
    > lone <input> elements for use with client-side scripting.
    >
    > --
    > Jukka K. Korpela ("Yucca")
    > http://www.cs.tut.fi/~jkorpela/


    Can anyone explain where are the code in
    http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
    that tells input tag can be outside of form tag but it must be e.g. inside
    div tag.

    This kind of issues can be tested by a validator but I would like know how
    to read it from DTD file's syntax.

    Cheers,
     
    Zone, Jan 23, 2008
    #5
  6. Scripsit Zone:

    > "Jukka K. Korpela" <> wrote in message
    > news:1jFlj.285172$...

    ....
    >> --
    >> Jukka K. Korpela ("Yucca")
    >> http://www.cs.tut.fi/~jkorpela/


    A comprehensive quote, down to a sig, is the usual sign of lack of
    comprehensive reading. Please keep using that style as long as you
    remain clueless. Using XHTML in web authoring isn't a _sure_ sign of
    cluelessness, you know, though often a useful hint.

    > Can anyone explain where are the code in
    > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
    > that tells input tag can be outside of form tag but it must be e.g.
    > inside div tag.


    Is that a serious question? It looks like one, but other symptoms
    suggest the opposite,

    Anyway, here are some crucial declarations from it:

    <!ENTITY % block
    "p | %heading; | div | %lists; | %blocktext; | fieldset | table">

    <!ENTITY % Block "(%block; | form | %misc;)*">

    <!ELEMENT body %Block;>

    Now, how can you have an <input> element inside the body? Hint: check
    the definition of %misc to see that there's nothing there that allows
    <input>. Then work out the declarations for the block-level elements
    like <p> and <div> to see that <input> is allowed there

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Jan 23, 2008
    #6
  7. Zone

    dorayme Guest

    In article <NmJlj.285285$>,
    "Jukka K. Korpela" <> wrote:

    > Scripsit Zone:
    >
    > > "Jukka K. Korpela" <> wrote in message
    > > news:1jFlj.285172$...

    > ...
    > >> --
    > >> Jukka K. Korpela ("Yucca")
    > >> http://www.cs.tut.fi/~jkorpela/

    >
    > A comprehensive quote, down to a sig, is the usual sign of lack of
    > comprehensive reading. Please keep using that style as long as you
    > remain clueless. Using XHTML in web authoring isn't a _sure_ sign of
    > cluelessness, you know, though often a useful hint.
    >
    > > Can anyone explain where are the code in
    > > http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd
    > > that tells input tag can be outside of form tag but it must be e.g.
    > > inside div tag.

    >
    > Is that a serious question? It looks like one, but other symptoms
    > suggest the opposite,
    >
    > Anyway, here are some crucial declarations from it:
    >
    > <!ENTITY % block
    > "p | %heading; | div | %lists; | %blocktext; | fieldset | table">
    >
    > <!ENTITY % Block "(%block; | form | %misc;)*">
    >
    > <!ELEMENT body %Block;>
    >
    > Now, how can you have an <input> element inside the body? Hint: check
    > the definition of %misc to see that there's nothing there that allows
    > <input>. Then work out the declarations for the block-level elements
    > like <p> and <div> to see that <input> is allowed there


    It's such a damn shame or a sight to behold (I rather fancy the
    latter, there being too many damn shames in this world already)
    that you can be so informative (the point about the %misc being
    something that perhaps only you and 4 others on the planet would
    have spotted *quickly*) yet give all this personally insulting
    preamble babble.

    How is it that something like me from a quite different planet
    can see that the OP is quite sincere and serious and you can't?
    Perhaps you need to get out of Iceland more often. Perhaps Bobby
    Fisher's late presence has had an unsettling effect deep down for
    years?

    --
    dorayme
     
    dorayme, Jan 23, 2008
    #7
  8. Scripsit dorayme:

    [ quoting something that he or she has almost nothing to say about, and
    no positive contribution ]

    > It's such a damn shame or a sight


    Excuse me while I yawn.

    > How is it that something like me from a quite different planet
    > can see that the OP is quite sincere and serious and you can't?


    If you quote like a moron, stay tuned to being treated like one.
    Sometimes you might get away with it, but that's not a reason to act
    moronically.

    --
    Jukka K. Korpela ("Yucca")
    http://www.cs.tut.fi/~jkorpela/
     
    Jukka K. Korpela, Jan 23, 2008
    #8
  9. Jukka K. Korpela wrote:
    > Scripsit dorayme:
    >
    > [ quoting something that he or she has almost nothing to say about, and
    > no positive contribution ]
    >
    >> It's such a damn shame or a sight

    >
    > Excuse me while I yawn.
    >
    >> How is it that something like me from a quite different planet
    >> can see that the OP is quite sincere and serious and you can't?

    >
    > If you quote like a moron, stay tuned to being treated like one.
    > Sometimes you might get away with it, but that's not a reason to act
    > moronically.
    >

    How about people who act like venom-spitting sociopaths? How should they
    expect to be treated?
     
    Harlan Messinger, Jan 23, 2008
    #9
  10. dorayme wrote:

    > Perhaps you need to get out of Iceland more often.


    Finland, Shirley?

    --
    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 24 days, 9:49.]

    CSS to HTML Compiler
    http://tobyinkster.co.uk/blog/2008/01/22/css-compile/
     
    Toby A Inkster, Jan 23, 2008
    #10
  11. Zone

    dorayme Guest

    In article <5n.co.uk>,
    Toby A Inkster <> wrote:

    > dorayme wrote:
    >
    > > Perhaps you need to get out of Iceland more often.

    >
    > Finland, Shirley?


    Mrs Goldberg is having a drink at the bar of her regular club
    when an oriental gentleman accidentally knocks over her drink.

    "You damned Japanese!" yells Mrs Goldberg. "First you gave us
    Pearl Harbour, now this!"

    "Hold on a minute. I'm not Japanese, I'm Chinese."

    "Chinese, Japanese — so what's in a name?"

    "And you Jews," replies the Chinese, "you can talk! You sank the
    Titanic!"

    "We sank what?" asked the astonished Mrs Goldberg, "The Titanic
    was sunk by an iceberg!"

    "Iceberg, Goldberg. So what's in a name?"

    --
    dorayme
     
    dorayme, Jan 24, 2008
    #11
    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. Tim_Mac
    Replies:
    3
    Views:
    1,359
    Steven Cheng[MSFT]
    Dec 16, 2005
  2. shruds
    Replies:
    1
    Views:
    836
    John C. Bollinger
    Jan 27, 2006
  3. Zone
    Replies:
    1
    Views:
    1,097
    Martin Honnen
    Jan 23, 2008
  4. André
    Replies:
    2
    Views:
    736
    André
    Jun 23, 2008
  5. john woo
    Replies:
    1
    Views:
    152
    David Dorward
    Jun 29, 2005
Loading...

Share This Page