Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    Regular Coder Apothem's Avatar
    Join Date
    Mar 2008
    Posts
    380
    Thanks
    36
    Thanked 25 Times in 25 Posts

    Can <select> elements be outside of the <form> element?

    This is probably common sense, but I blatantly don't know a lot of HTML rules. So if I place <select> elements out of <form> elements, will I be violating HTML standards? If it is, is there an alternative to using <select> elements?

  • #2
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    616
    Thanks
    48
    Thanked 65 Times in 65 Posts
    No, <select> doesn't have to be inside a form. Some sites (jsrdirect.com, where I like to buy my shirts) use dropdown menus for links, which is one way they can be used outside of their most common form use.
    "Yeah science!"
    Online Science Tools

  • #3
    The fat guy next door VIPStephan's Avatar
    Join Date
    Jan 2006
    Location
    Halle (Saale), Germany
    Posts
    8,696
    Thanks
    6
    Thanked 1,011 Times in 984 Posts
    Quote Originally Posted by djh101 View Post
    No, <select> doesn't have to be inside a form.
    Wow, that’s news to me. I could have sworn it wasn’t allowed. But anyway, apart from that the question is: What does a select element do by nature (that means without the help of JavaScript or a form’s submit button)?

    Is the answer “nothing”? Well, then it is certainly not correct to use it outside of a form, semantics wise.

  • #4
    Regular Coder djh101's Avatar
    Join Date
    May 2009
    Location
    California
    Posts
    616
    Thanks
    48
    Thanked 65 Times in 65 Posts
    It was intended for forms, but I don't think it's actually bad syntax to use it outside. Maybe it is just with Javascript, but I have seen a lot of sites that use it outside forms. Correct me if I'm wrong.

    Okay, I'll correct myself. You're right, I think it is improper to use it outside a form. Sorry for that.
    Last edited by djh101; 08-03-2010 at 07:35 PM.
    "Yeah science!"
    Online Science Tools

  • #5
    Regular Coder
    Join Date
    Aug 2005
    Location
    MS
    Posts
    833
    Thanks
    10
    Thanked 79 Times in 77 Posts
    As far as I know, the select tags are suppose to be placed between the form tags with the proper syntax. It may work without them, but it is not syntactically correct. Leaving out the form's action="" even if there is no action will get it flagged by validator. Maybe HTML 5 will address this better.
    ☠ ☠RON☠ ☠


  •  

    Posting Permissions

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