quotes around some attributes in forms

Discussion in 'HTML' started by dorayme, Nov 29, 2005.

  1. dorayme

    dorayme Guest

    I have noticed that type=hidden is often written without quotes.
    For example see
    http://www.scriptarchive.com/readme/formmail.html#recipient who
    seems to know what he is talking about. Is this so, or would it
    be better practice to use quotes as in type="hidden"? He uses
    the quotes on name="" and value="" but not on type="" I have
    seen this before I think. Is there any good reason?

    --
    dorayme
     
    dorayme, Nov 29, 2005
    #1
    1. Advertising

  2. dorayme wrote:

    > I have noticed that type=hidden is often written without quotes.
    > Is this so, or would it be better practice to use quotes as in
    > type="hidden"?


    In certain cases, authors may specify the value of an attribute without
    any quotation marks. The attribute value may only contain letters (a-z
    and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII
    decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal
    58). We recommend using quotation marks even when it is possible to
    eliminate them.

    -- http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2

    --
    David Dorward <http://blog.dorward.me.uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is
     
    David Dorward, Nov 30, 2005
    #2
    1. Advertising

  3. dorayme

    rf Guest

    dorayme wrote:

    > I have noticed that type=hidden is often written without quotes.
    > For example see
    > http://www.scriptarchive.com/readme/formmail.html#recipient who
    > seems to know what he is talking about. Is this so, or would it
    > be better practice to use quotes as in type="hidden"?


    The HTML specs state that attribute values that contain special characters
    (those other than alphanumeric and a few others) must be quoted. Attribute
    values without special characters don't need to be quoted. Certainly if a
    value contains a space it must be quoted.

    > He uses
    > the quotes on name="" and value="" but not on type="" I have
    > seen this before I think. Is there any good reason?


    Sloppy coding?

    I use quotes for every attribute value rather than relying on remembering
    correctly which special characters require quotes.

    Additionally, some browsers will accept unquoted values *with* some special
    characters. Some browsers will barf on exactly the same value.

    1) Don't quote, risk making a mistake that *may not be picked up* in your
    test browsers (should be by the validator though) but will break in one of
    your viewers browser.

    2) Quote everything and be quite safe.

    The quotes are required in XHTML anyway, if that ever eventuates.

    --
    Cheers, Richard.
     
    rf, Nov 30, 2005
    #3
  4. dorayme

    dorayme Guest

    > From: David Dorward <>
    >
    > dorayme wrote:
    >
    >> I have noticed that type=hidden is often written without quotes.
    >> Is this so, or would it be better practice to use quotes as in
    >> type="hidden"?

    >
    > In certain cases, authors may specify the value of an attribute without
    > any quotation marks. The attribute value may only contain letters (a-z
    > and A-Z), digits (0-9), hyphens (ASCII decimal 45), periods (ASCII
    > decimal 46), underscores (ASCII decimal 95), and colons (ASCII decimal
    > 58). We recommend using quotation marks even when it is possible to
    > eliminate them.
    >
    > -- http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
    >


    OK, so it can be strictly ok not to quote; but best to do anyway
    so as not to have to remember which chars actually bring in the
    requirement. Thank you DD and rf.

    --
    dorayme
     
    dorayme, Nov 30, 2005
    #4
  5. dorayme

    Neredbojias Guest

    With neither quill nor qualm, dorayme quothed:

    > I have noticed that type=hidden is often written without quotes.
    > For example see
    > http://www.scriptarchive.com/readme/formmail.html#recipient who
    > seems to know what he is talking about. Is this so, or would it
    > be better practice to use quotes as in type="hidden"? He uses
    > the quotes on name="" and value="" but not on type="" I have
    > seen this before I think. Is there any good reason?


    I think it's to emphasize that the type is, indeed, hidden.

    --
    Neredbojias
    Contrary to popular belief, it is believable.
     
    Neredbojias, Nov 30, 2005
    #5
    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. Eric
    Replies:
    2
    Views:
    1,566
    Tommy
    Feb 13, 2004
  2. Chris White

    Quotes/Double Quotes in Image Control

    Chris White, Sep 22, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    4,915
    Hermit Dave
    Sep 22, 2004
  3. Chris
    Replies:
    1
    Views:
    13,762
    Oisin
    Mar 24, 2006
  4. Lawrence Tierney

    Multiline quotes - escaping quotes - et al

    Lawrence Tierney, Dec 24, 2003, in forum: Java
    Replies:
    3
    Views:
    4,550
    Andrew Thompson
    Dec 24, 2003
  5. Network/Software Buyer
    Replies:
    0
    Views:
    442
    Network/Software Buyer
    May 23, 2010
Loading...

Share This Page