CKTIS / HTML
wrap — textarea wrapping for submission
The textarea wrap attribute determines whether the browser adds line breaks to the value submitted with a form. It distinguishes visible line wrapping from actual newline characters.
Version: WHATWG HTML Living Standard; index snapshot date recorded separately
Syntax
<textarea wrap="soft">…</textarea>
<textarea wrap="hard" cols="20">…</textarea>wrap is an enumerated attribute of textarea, not a boolean attribute. Its keywords are soft and hard. An omitted attribute or an invalid value selects the soft state.
With soft, the browser can wrap text visually without adding submission line breaks for that wrapping. User-entered line breaks remain part of the text. With hard, the browser inserts LF (U+000A) characters into the submission value so that lines do not exceed the character width specified by cols. In this state, you must provide cols as a positive integer.
The exact wrapping algorithm is implementation-defined: do not assume identical break positions across browsers. Additional breaks produced by hard are not inserted into the .value property, which exposes the API value with line breaks normalized to LF.
The example changes wrap through its DOM property and shows that .value stays unchanged. It does not test wrapping positions in submitted form data.
Examples
<!doctype html>
<meta charset="utf-8">
<title>wrap</title>
<label for="note">Text</label>
<textarea id="note" wrap="soft" cols="5">alpha beta gamma</textarea>
<pre id="result"></pre>
<script>
const note = document.getElementById("note");
const result = document.getElementById("result");
const before = note.value;
note.wrap = "hard";
result.textContent = JSON.stringify({
wrap: note.wrap,
unchanged: note.value === before,
value: note.value
});
</script>Result
{"wrap":"hard","unchanged":true,"value":"alpha beta gamma"}The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.