View Full Version : Can <select> elements be outside of the <form> element?

08-03-2010, 12:39 AM
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?

08-03-2010, 01:38 AM
No, <select> doesn't have to be inside a form. Some sites (jsrdirect.com (http://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.

08-03-2010, 03:52 PM
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.

08-03-2010, 07:31 PM
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.

Major Payne
08-03-2010, 07:43 PM
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.