Search code examples
htmltagsattributes

Why select is not a input type in HTML?


Why for example <select> and <textarea> are stand alone tags instead of attributes of <input>?


Solution

  • So to provide a hopefully more complete answer incorporating some information from @BackMaba07's answer:

    HTML (wikipedia article) has been an evolving standard, it was based originally on SGML. Over time it was developed and extended. The tags for web forms are clearly specified in the HTML 2.0 standard where <INPUT>, <SELECT> and <TEXTAREA> are defined separately, probably for the reasons BlackMamba07 describes:

    <select> is a nested HTML Element, whereas is not. For example <select> element contains elements nested within it.

    As far as <textarea> is concerned, in the initial design for forms, multi-line text fields were supported by the Input element with TYPE=TEXT. Unfortunately, this causes problems for fields with long text values. SGML's default (Reference Quantity Set) limits the length of attribute literals to only 240 characters. The HTML 2.0 SGML declaration increases the limit to 1024 characters.)

    Subsequent versions of HTML have involved lots of arguing and negotiation and discussion between the involved parties, including WHATWG and the W3C.

    Although a case could probably be made that having form elements that are not inputs is annoying if you want to use scripting or CSS to change all elements in a form, it has probably never been a big enough issue to make it to the discussion table.

    There are no absolutes, just a bunch of old men (and I'm happy to say, increasingly women, and young people) arguing about standards.

    There is considerable debate even here at SO about what specification applies. For example: HTML5: W3C vs WHATWG. Which gives the most authoritative spec?

    The exciting part is, if you care enough, you can join the conversation, and have your say. You will be up against some seasoned campaigners tho. Have fun!