Why isn't textarea an input[type="textarea"]?
Maybe this is going a bit too far back but…
Also, I’d like to suggest that multiline text fields have a different type (e.g. “textarea") than single-line fields ("text"), as they really are different types of things, and imply different issues (semantics) for client-side handling.
– Marc Andreessen, 11 October 1993
So that its value can easily contain quotes and <> characters and respect whitespace and newlines.
The following HTML code successfully pass the w3c validator and displays <,> and & without the need to encode them. It also respects the white spaces.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Yes I can</title>
</head>
<body>
<textarea name="test">
I can put < and > and & signs in
my textarea without any problems.
</textarea>
</body>
</html>
A textarea
can contain multiple lines of text, so one wouldn't be able to pre-populate it using a value
attribute.
Similarly, the select
element needs to be its own element to accommodate option
sub-elements.