References

Beginner-friendly references for web development, with live, editable examples.

The HTML wrap attribute

Attribute All modern browsers Updated
Quick answer

The HTML wrap attribute controls how line breaks are handled in the submitted value. It is used on the <textarea> element.

Overview

The wrap attribute controls how line breaks are handled in the submitted value. It applies to the <textarea> element.

With hard you must also set cols; the browser then inserts real line breaks at wrap points in the submitted text.

Syntax

<textarea wrap="hard" cols="20"></textarea>

Values

Value
soft (default) | hard

Best practices

  • Set the visible size with rows (and cols), or with CSS height.
  • Pair the textarea with a <label>.
  • Use the CSS resize property if the drag-to-resize handle does not suit your layout.
  • Limit length with the maxlength attribute.

Frequently asked questions

What does the wrap attribute do?
Controls textarea line wrapping on submit.
How do I set the size of a textarea?
Use the rows and cols attributes, or set its width and height with CSS.
Which elements use the wrap attribute?
It is an element-specific attribute, used on the <textarea> element.