HTML wrap Attribute

The HTML wrap attribute defines how the text in a text area is to be wrapped when a form is submitted in an HTML document.


Following is the syntax −

<textarea wrap=”hard | soft”></textarea>

Let us see an example of HTML wrap Attribute −


 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>HTML wrap Attribute Demo</h1>
<form action='' method="post">
<textarea rows="5" cols="28" wrap="soft">Hi! I'm a text area element with some dummy text.</textarea>
<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: