whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
7.86k stars 2.57k forks source link

textarea: attribute for content type #10161

Open vanillajonathan opened 4 months ago

vanillajonathan commented 4 months ago

What problem are you trying to solve?

The user agents, bots, and scripts know nothing of the content of the textarea and cannot provide syntax highlighting or input validation.

The textarea element does convey semantics as to what the content is other than its natural language via the lang attribute.

What solutions exist today?

None, but you can use your own custom data- attributes but then there is no standard for it and it only works with your scripts.

You can use JavaScript libraries such as Ace, CodeMirror or Monaco if you want a nice experience but the markup has no semantics.

How would you solve it?

Add a attribute to to the textarea element.

Example:

<textarea enctype="application/json">{}</textarea>

or:

<textarea codelang="python">fruits = ["apple", "banana", "orange"]</textarea>

Anything else?

No response

Delapouite commented 2 months ago

Related issue https://github.com/WICG/proposals/issues/136