- HTML Tutorial
- HTML - Home
- HTML - History and Evolution
- HTML - Overview
- HTML - Editors
- HTML - Basic Tags
- HTML - Elements
- HTML - Attributes
- HTML - Formatting
- HTML - Headings
- HTML - Paragraphs
- HTML - Quotations
- HTML - Comments
- HTML - Phrase Tags
- HTML - Meta Tags
- HTML - Style Sheet
- HTML - CSS Classes
- HTML - CSS IDs
- HTML - Images
- HTML - Image Map
- HTML Tables
- HTML - Tables
- HTML - Headers & Caption
- HTML - Table Styling
- HTML - Table Colgroup
- HTML - Nested Tables
- HTML Lists
- HTML - Lists
- HTML - Unordered Lists
- HTML - Ordered Lists
- HTML - Definition Lists
- HTML Links
- HTML - Text Links
- HTML - Image Links
- HTML - Email Links
- HTML - Iframes
- HTML - Blocks
- HTML Backgrounds
- HTML - Backgrounds
- HTML Colors
- HTML - Colors
- HTML - RGB
- HTML - HEX
- HTML - HSL
- HTML Forms
- HTML - Forms
- HTML - Form Attributes
- HTML - Form Control
- HTML - Input Attributes
- HTML Media
- HTML - Video Element
- HTML - Audio Element
- HTML - Embed Multimedia
- HTML Header
- HTML - Head Element
- HTML - Adding Favicon
- HTML - Javascript
- HTML Layouts
- HTML - Layouts
- HTML - Layout Elements
- HTML - Layout using CSS
- HTML - Responsiveness
- HTML - Symbols
- HTML - Emojis
- HTML - Style Guide
- HTML Graphics
- HTML - SVG
- HTML - Canvas
- HTML APIs
- HTML - Geolocation API
- HTML - Drag & Drop API
- HTML - Web Workers API
- HTML - WebSocket
- HTML - Web Storage
- HTML - Server Sent Events
- HTML Miscellaneous
- HTML - MathML
- HTML - Microdata
- HTML - IndexedDB
- HTML - Web Messaging
- HTML - Web CORS
- HTML - Web RTC
- HTML Demo
- HTML - Audio Player
- HTML - Video Player
- HTML - Web slide Desk
- HTML Tools
- HTML - Velocity Draw
- HTML - QR Code
- HTML - Modernizer
- HTML - Validation
- HTML - Color Code Builder
- HTML References
- HTML - Tags Reference
- HTML - Attributes Reference
- HTML - Events Reference
- HTML - Fonts Reference
- HTML - ASCII Codes
- ASCII Table Lookup
- HTML - Color Names
- HTML - Entities
- MIME Media Types
- HTML - URL Encoding
- Language ISO Codes
- HTML - Character Encodings
- HTML - Deprecated Tags
- HTML Resources
- HTML - Quick Guide
- HTML - Useful Resources
- HTML - Color Code Builder
- HTML - Online Editor
HTML - wrap Attribute
The wrap attribute of HTML is used to wrap the text in a text area when submitted in a HTML form. This attribute can be applied on the <textarea> element.
This attribute takes following values−
- Soft − This is the default value. It specifies that the text in the textarea will not be wrapped when the form is submitted.
- Hard − It defines that the text in a textarea wraps when the form is submitted.
Syntax
Following is the syntax of the wrap attribute −
<textarea wrap="soft|hard"> ...content </textarea>
Example
In the following example, we are using the wrap attribute with the value "hard" in the <textarea> tag.
<!DOCTYPE html> <html> <body> <h1>The textarea wrap attribute</h1> <form action="https://www.tutorialspoint.com/index.htm"> <textarea rows="3" cols="20" name="usrtxt" wrap="hard"> At tutorialspoint you will find free Web-building tutorials. </textarea> <br> <input type="submit"> </form> </body> </html>
On running the above code, it will generate an output consisting of the textarea field along with a click button on the webpage.
Example
Considering the another scenario, where we are using the wrap attribute with value "soft" in the <textarea> tag.
<!DOCTYPE html> <html> <body> <h1>The textarea wrap attribute</h1> <form action="https://www.tutorialspoint.com/index.htm"> <textarea rows="3" cols="20" name="usrtxt" wrap="soft"> At tutorialspoint you will find free Web-building tutorials. </textarea> <br> <input type="submit"> </form> </body> </html>
When we run the above code, it will generate an output consisting of the textarea field along with a click button displayed on the webpage.
Example
Let's look at the following example, where we are going to use the wrap attribute with the value "soft" Here, we have created two buttons: the first will submit the form, and the second will show the wrap value.
<!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="3" 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>
On running the above code, the output window will pop up displaying the textarea field along with two buttons on the webpage.
To Continue Learning Please Login
Login with Google