Why isn't <textarea> self closing? [duplicate]

喜你入骨 提交于 2019-11-30 08:07:46

问题


I've been wondering why none of the revisions to the HTML specification have ever made textarea able to be self-closing. Lot's of SO questions have answered why it is a separate tag from input, and it makes sense to me that they'd want to preserve it as a separate tag for compatibility, but why wouldn't they make <textarea /> just as valid as <textarea></textarea> since this wouldn't break anything as far as I can tell.


回答1:


Because <input /> can't work like container for text, While <textarea> text goes here</textarea> can work as container for default text!

Here is what explain your curiosity about why they choose to go this way.

textarea {
  width: 300px;
  height: 100px;
}
<!-- Easy way for default input text -->
<textarea>Here is why because text can be input into box like paragraph tag</textarea>


来源:https://stackoverflow.com/questions/34729059/why-isnt-textarea-self-closing

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!