Textarea wrap Property - Javascript DOM HTML Element

Javascript examples for DOM HTML Element:Textarea


The wrap property sets or gets the wrap attribute of a text area.

Set the wrap property with the following Values

Value Description
soft The text in the text area is not wrapped when submitted in a form. This is default
hard The text in the text area contains newlines when submitted in a form.

When "hard" is used, the cols attribute must be specified

Return Value

A String, representing how the text area wraps text when submitted in a form

The following code shows how to check how the text in a text area should be wrapped when submitting a form:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>

<form action="#">
<textarea id="myTextarea" rows="2" cols="20" name="usrtxt" wrap="hard">
new value//from ww  w  .ja  v a2  s.  c  o  m
<input type="submit">

<button onclick="myFunction()">Test</button>

<p id="demo"></p>

function myFunction() {
    var x = document.getElementById("myTextarea").wrap;
    document.getElementById("demo").innerHTML = x;


Related Tutorials