Whatever message this page gives is out now! Go check it out!

Wrap

Last update:
May 18, 2026

Description

Wraps text so that each line has a specified maximum number of characters.
Note: The wrap function does not insert line breaks by placing the <br> tag in HTML text. Instead, it wraps the text in the display without adding the <br> tag.

Returns

String containing the wrapped text.

Category

Function syntax

Wrap(string, limit[, strip])

See also

History

ColdFusion MX 6.1: Added this function.

Parameters

Parameter
Description
string
String or variable that contains one. The text to wrap.
limit
Positive integer maximum number of characters to allow on a line.
strip
Boolean value specifying whether to remove all existing newline and carriage return characters in the input string with spaces before wrapping the text. The default value is False.

Usage

Inserts line break at the location of the first white space character (such as a space, tab, or new line) before the specified limit on a line. If a line has no whitespace characters before the limit, inserts a line break at the limit. Uses the operating-system specific line break: newline for UNIX, carriage return and newline on Windows.If you specify the strip parameter, all existing line breaks are removed, so any paragraph formatting is lost.Use this function to limit the length of text lines, such as text to be included in a mail message. The cfmail and cfmailpart tag wraptext attributes use this function

Example

<cfscript>
   inputText="This is an example of a text message that we want to wrap. It is rather long and needs to be broken into shorter lines." 
   writeOutput(Wrap(inputText, 5,0))
</cfscript>
Output
This is an examp le of a text mess age that we want to wrap . It is rath er long and need s to be brok en into shor ter line s.

Share this page

Was this page helpful?
We're glad. Tell us how this page helped.
We're sorry. Can you tell us what didn't work for you?
Thank you for your feedback. Your response will help improve this page.

On this page