Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

html

w3c

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.

like image 951
Matthew Avatar asked Jan 11 '16 19:01

Matthew


People also ask

Does textarea need closing tag?

The <textarea> tag defines a form field where user can input a multi-line text. Unlike the <input> tag, text wrapping inside <textarea> is allowed when the form is submitted. A text area can have an unlimited number of characters. The text within this tag is rendered in a fixed-width font (usually Courier).

Is textarea self closing in react?

For React, it's mostly a convention. One convention is to always use self-closing tags if there is no content ( children) inside of your component. So for a textarea it would be self closing.

Can script tags Self close?

That's because SCRIPT TAG is not a VOID ELEMENT. In an HTML Document - VOID ELEMENTS do not need a "closing tag" at all!

Is textarea inline or block?

<textarea> is a replaced element — it has intrinsic dimensions, like a raster image. By default, its display value is inline-block .


1 Answers

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>
like image 142
AmJustSam Avatar answered Oct 01 '22 13:10

AmJustSam