SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Wizard mPeror's Avatar
    Join Date
    Mar 2005
    Location
    Saudi Arabia
    Posts
    1,724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    <select> and <option> causing validation troubles

    I'm trying to validate this page and this page but i'm having problem with the forms elements <select> , <option> and <input> . What's stopping my code from validating?


    any help is much appreciated

  2. #2
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by mPeror
    I'm trying to validate this page and this page but i'm having problem with the forms elements <select> , <option> and <input> . What's stopping my code from validating?


    any help is much appreciated
    Because selected by itself is not valid XHTML. Attributes need to be in quotes. Use selected="selected"
    Aaron Brazell
    Technosailor



  3. #3
    SitePoint Wizard mPeror's Avatar
    Join Date
    Mar 2005
    Location
    Saudi Arabia
    Posts
    1,724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    oops , i think i forgot to close those <option> tags (used to HTML 4.0).

    btw , why do i have to put a form within a block-level element in order for the document to validate?

  4. #4
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    because the only block level element allowed to contain another block level element in the XHTML Strict spec is a <div>
    Aaron Brazell
    Technosailor



  5. #5
    SitePoint Wizard mPeror's Avatar
    Join Date
    Mar 2005
    Location
    Saudi Arabia
    Posts
    1,724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I've actually used the <p> tag . How did it validate then?

  6. #6
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Sketch
    because the only block level element allowed to contain another block level element in the XHTML Strict spec is a <div>
    This is not correct. FORM, FIELDSET, BLOCKQUOTE and NOSCRIPT are also block-level and may (some must) contain block-level children.
    Quote Originally Posted by mPeror
    btw , why do i have to put a form within a block-level element in order for the document to validate?
    You don't. You can put a FORM as a direct child of BODY, and it will be valid.

    You must, however, have block-level children of the FORM itself.
    Simon Pieters

  7. #7
    SitePoint Wizard mPeror's Avatar
    Join Date
    Mar 2005
    Location
    Saudi Arabia
    Posts
    1,724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You must, however, have block-level children of the FORM itself.
    Do you mean there are some inline child form elements that i need to enclose in block elements or what?

  8. #8
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by mPeror
    I've actually used the <p> tag . How did it validate then?
    Because a paragraph is also a block-level element.

  9. #9
    SitePoint Wizard mPeror's Avatar
    Join Date
    Mar 2005
    Location
    Saudi Arabia
    Posts
    1,724
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yea i know but my question is why do i have to enclose the <select> with a block-level element? i've used <p> , and if i remove it ; the document wouldn't validate.

  10. #10
    bronze trophy
    Join Date
    Dec 2004
    Location
    Sweden
    Posts
    2,670
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT is inline-level, so it can't be a direct child of FORM, since FORM can only contain block-level children.
    Simon Pieters


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
  •