Content · Web Development · HTML

HTML wrap Attribute: Reference and Examples

A clear, practical attribute reference to wrap. Learn when to use it, see working HTML, and avoid common mistakes.

1 views Published Oct 19, 2026 Updated Oct 19, 2026 Admin

The wrap attribute is a small instruction attached to an HTML element. Its job is to control textarea submitted line wrapping behavior. It is easier to remember when you can see it in a real piece of markup.

What wrap is used for


Control textarea submitted line wrapping behavior. The attribute appears inside an element’s opening tag. Depending on its definition, it may take a specific string, a number, an enumerated keyword, or be a boolean attribute.

The example below uses it in a textarea context. Other elements may support it too, or may give the same attribute a different meaning.

Example you can try


<label for="message">Message</label>
<textarea id="message" name="message" rows="5" cols="40" wrap="hard">Write here</textarea>

How the example works


Look for wrap in the snippet. Here the example shows the value hard. This is a concrete input the browser can interpret; it is not just text shown to the reader.

Hard wrapping of textarea text affects submitted line breaks when combined with required rows/cols constraints.

Values and important behavior


soft does not add display-based line breaks to the submitted value; hard adds wrapping line breaks and requires cols.

This detail matters most when the page receives user input, navigates to another document, or loads an external resource. In those cases, check the browser behavior and any server-side requirements separately.

Small practice task


Copy the code and change wrap to another sensible value, or remove it entirely if it is optional. Test the difference in the browser and inspect any submitted value or network request.

Common Beginner Mistakes


  • Hard wrapping of textarea text affects submitted line breaks when combined with required rows/cols constraints.
  • Using wrap on an element that does not support it.
  • Believing that an HTML hint or client-side check replaces real server validation or a security policy.

Key Takeaways


  • wrap is used to control textarea submitted line wrapping behavior.
  • Hard wrapping of textarea text affects submitted line breaks when combined with required rows/cols constraints.
  • Choose valid values and test the result instead of guessing what the browser will do.
Share this resourceSend this page to someone who may find it useful.