HTML DOM Textarea wrap Property

The HTML DOM Textarea wrap property returns and modify the value of wrap attribute of a text area element in an HTML document.


Following is the syntax −

1. Returning wrap


2. Adding wrap

object.wrap = soft | hard

Let us see an example of HTML DOM Textarea wrap Property:


Live Demo

<!DOCTYPE html>
   body {
      color: #000;
      height: 100vh;
   .btn {
      background: #db133a;
      border: none;
      height: 2rem;
      border-radius: 2px;
      width: 40%;
      display: block;
      color: #fff;
      outline: none;
      cursor: pointer;
      margin: 1rem 0;
   .show {
      font-size: 1.5rem;
      margin: 1rem 0;
<h1>DOM Textarea wrap Property Demo</h1>
<form action='' method="post">
<textarea rows="5" cols="28" wrap="soft">
Hi! I'm a text area element with some dummy text.
<input type="submit" class='btn' value="Submit Form">
<button onclick="set()" class="btn">Show wrap value</button>
<div class="show"></div>
   function set() {
      document.querySelector('.show').innerHTML = "The value of wrap attribute is " + document.querySelector("textarea").wrap;


Click on “Show wrap value” button to display the value of wrap attribute of the textarea element.

Updated on: 16-Feb-2021


Kickstart Your Career

Get certified by completing the course

Get Started