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.
Asked
Active
Viewed 9,776 times
20
-
3Quote: *"this wouldn't break anything"* ~ It would. Because `` is a container and `` is not. `` – Sparky Jan 11 '16 at 19:06
-
Exactly the same reason as for `script` elements: [Why don't self-closing script tags work?](http://stackoverflow.com/q/69913/1529630) – Oriol Jan 11 '16 at 19:14
1 Answers
10
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>