This question already has an answer here:
- Why don't self-closing script elements work? 11 answers
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.
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