- Attribute of
- <textarea> HTML Tag
- What does
- Determines whether or not submitted text wraps when a <textarea> is included in a form submission.
Forcing Newlines in a Submitted Textarea
wrap attribute is used to tell the browser whether or not to add newlines when a form is submitted so that the text is wrapped at a defined width. There are two possible values used with the
hard. If the
soft value is used, no newlines will be added to the submitted value. If the
hard value is used a newline character (a
cols attribute. For example, when the text area below was submitted a newline would be added after ever 40 characters.
CSS is often used to control the rendering or presentation of a
textarea. However, regardless of how the
textarea is presented visually in a browser, the newline characters will be added on the basis of where the
cols attribute dictates they should be added. So, when we render the
textarea above with the CSS
width property set to 100% it displays at the full width of the parent element. However, when submitted, a carriage return would be added after every 20 characters.