SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Member
    Join Date
    Jan 2003
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    XHTML Strict + Submitting Forms?

    If you are following XHTML 1.0 Strict and specify the id attribute as opposed to the name attribute, how do you handle submitting a form to a backend application? Name is what is passed to the form, not id, unless I'm missing something.

  2. #2
    He's No Good To Me Dead silver trophybronze trophy stymiee's Avatar
    Join Date
    Feb 2003
    Location
    Slave I
    Posts
    23,426
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    You can still use name in XHTML. Forms won't work without them.

  3. #3
    SitePoint Member
    Join Date
    Jan 2003
    Posts
    18
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by stymiee
    You can still use name in XHTML. Forms won't work without them.
    But based off of the XHTML 1.0 Spec [http://www.w3.org/TR/xhtml1/#h-4.10]


    4.10. The elements with 'id' and 'name' attributes

    HTML 4 defined the name attribute for the elements a, applet, form, frame, iframe, img, and map. HTML 4 also introduced the id attribute. Both of these attributes are designed to be used as fragment identifiers.

    In XML, fragment identifiers are of type ID, and there can only be a single attribute of type ID per element. Therefore, in XHTML 1.0 the id attribute is defined to be of type ID. In order to ensure that XHTML 1.0 documents are well-structured XML documents, XHTML 1.0 documents MUST use the id attribute when defining fragment identifiers on the elements listed above. See the HTML Compatibility Guidelines for information on ensuring such anchors are backward compatible when serving XHTML documents as media type text/html.

    Note that in XHTML 1.0, the name attribute of these elements is formally deprecated, and will be removed in a subsequent version of XHTML.
    So I'm confused... is name deprecated or required?


    Ah I see... name is only deprecated for certain elements.

  4. #4
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Form fields (textboxes, radio buttons, etc.) still use name.

  5. #5
    SitePoint Author silver trophybronze trophy

    Join Date
    Nov 2004
    Location
    Ankh-Morpork
    Posts
    12,158
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You don't need name for the form itself, but you will need it for the form controls that need to be submitted to the server.

    The id attribute replaces name for a number of element types, when it comes to identifying the element. For form controls, however, it's a different matter. Multiple form controls can share the same name, e.g., in the case of radio buttons. That cannot be achieve with ids, which must be unique.
    Birnam wood is come to Dunsinane


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •