10

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

ycshao
  • 1,768
  • 4
  • 18
  • 32
  • 1
    Because history. https://en.wikipedia.org/wiki/HTML5. When HTML was a baby it had separate tags, and then they stayed that way because too much change hurts. If you think it should change, join the team writing the specification for HTML6? – Tim Ogilvy Mar 23 '16 at 03:06
  • @TimOgilvy that could be an answer, and avoid closing this question (which without your comment adds little value). – nha Mar 23 '16 at 09:25
  • 1
    @nha thanks. I had a go. – Tim Ogilvy Mar 27 '16 at 05:35
  • 1
    I agree with the answer, js also has a lot of inconsistency linked to these first versions which could never be patched in order to avoid break changes and destabilize all the worldwide applications parc. It one raison why you have strange thing like `1-'1'=>0`, `1+'1'=>11` ! – jon Jan 26 '22 at 22:23

2 Answers2

9

<select> is a nested HTML Element, whereas <input> is not. For example <select> element contains <option> 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.)

I guess this is the reason why we have seperate tags for these elements.

SachinSunny
  • 1,681
  • 1
  • 12
  • 20
3

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!

Community
  • 1
  • 1
Tim Ogilvy
  • 1,923
  • 1
  • 24
  • 36