HTML wrap Attribute

HTMLWeb DevelopmentFront End Technology

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.

Syntax

Following is the syntax −

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

Let us see an example of HTML wrap Attribute −

Example

 Live Demo

<!DOCTYPE html>
<html>
<style>
   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;
   }
</style>
<body>
<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">
</form>
<button onclick="set()" class="btn">Show wrap value</button>
<div class="show"></div>
<script>
   function set() {
      document.querySelector('.show').innerHTML = "The value of wrap attribute is " +       document.querySelector("textarea").wrap;
   }
</script>
</body>
</html>

Output

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

raja
Published on 01-Oct-2019 10:35:31
Advertisements