- CSS - Home
- CSS - Roadmap
- CSS - Introduction
- CSS - Syntax
- CSS - Inclusion
- CSS - Types
- CSS - Measurement Units
- CSS - Selectors
- CSS - Colors
- CSS - Backgrounds
- CSS - Fonts
- CSS - Text
- CSS - Images
- CSS - Links
- CSS - Tables
- CSS - Borders
- CSS - Border Block
- CSS - Border Inline
- CSS - Margins
- CSS - Lists
- CSS - Padding
- CSS - Cursor
- CSS - Outlines
- CSS - Dimension
- CSS - Scrollbars
- CSS - Inline Block
- CSS - Dropdowns
- CSS - Visibility
- CSS - Overflow
- CSS - Clearfix
- CSS - Float
- CSS - Arrows
- CSS - Resize
- CSS - Quotes
- CSS - Order
- CSS - Position
- CSS - Hyphens
- CSS - Hover
- CSS - Display
- CSS - Focus
- CSS - Zoom
- CSS - Translate
- CSS - Height
- CSS - Hyphenate Character
- CSS - Width
- CSS - Opacity
- CSS - Z-Index
- CSS - Bottom
- CSS - Navbar
- CSS - Overlay
- CSS - Forms
- CSS - Align
- CSS - Icons
- CSS - Image Gallery
- CSS - Comments
- CSS - Loaders
- CSS - Attr Selectors
- CSS - Combinators
- CSS - Root
- CSS - Box Model
- CSS - Counters
- CSS - Clip
- CSS - Writing Mode
- CSS - Unicode-bidi
- CSS - min-content
- CSS - All
- CSS - Inset
- CSS - Isolation
- CSS - Overscroll
- CSS - Justify Items
- CSS - Justify Self
- CSS - Tab Size
- CSS - Pointer Events
- CSS - Place Content
- CSS - Place Items
- CSS - Place Self
- CSS - Max Block Size
- CSS - Min Block Size
- CSS - Mix Blend Mode
- CSS - Max Inline Size
- CSS - Min Inline Size
- CSS - Offset
- CSS - Accent Color
- CSS - User Select
- CSS - Cascading
- CSS - Universal Selectors
- CSS - ID Selectors
- CSS - Group Selectors
- CSS - Class Selectors
- CSS - Child Selectors
- CSS - Element Selectors
- CSS - Descendant Selectors
- CSS - General Sibling Selectors
- CSS - Adjacent Sibling Selectors
- CSS Advanced
- CSS - Grid
- CSS - Grid Layout
- CSS - Flexbox
- CSS - Visibility
- CSS - Positioning
- CSS - Layers
- CSS - Pseudo Classes
- CSS - Pseudo Elements
- CSS - @ Rules
- CSS - Text Effects
- CSS - Paged Media
- CSS - Printing
- CSS - Layouts
- CSS - Validations
- CSS - Image Sprites
- CSS - Important
- CSS - Data Types
- CSS3 Advanced Features
- CSS - Rounded Corner
- CSS - Border Images
- CSS - Multi Background
- CSS - Color
- CSS - Gradients
- CSS - Box Shadow
- CSS - Box Decoration Break
- CSS - Caret Color
- CSS - Text Shadow
- CSS - Text
- CSS - 2d transform
- CSS - 3d transform
- CSS - Transition
- CSS - Animation
- CSS - Multi columns
- CSS - Box Sizing
- CSS - Tooltips
- CSS - Buttons
- CSS - Pagination
- CSS - Variables
- CSS - Media Queries
- CSS - Functions
- CSS - Math Functions
- CSS - Masking
- CSS - Shapes
- CSS - Style Images
- CSS - Specificity
- CSS - Custom Properties
- CSS Responsive
- CSS RWD - Introduction
- CSS RWD - Viewport
- CSS RWD - Grid View
- CSS RWD - Media Queries
- CSS RWD - Images
- CSS RWD - Videos
- CSS RWD - Frameworks
- CSS References
- CSS Interview Questions
- CSS Online Quiz
- CSS Online Test
- CSS Mock Test
- CSS - Quick Guide
- CSS - Cheatsheet
- CSS - Properties References
- CSS - Functions References
- CSS - Color References
- CSS - Web Browser References
- CSS - Web Safe Fonts
- CSS - Units
- CSS - Animation
- CSS Resources
- CSS - Useful Resources
- CSS - Discussion
CSS - text-wrap Property
CSS text-wrap property controls how text wraps within an element. It determines whether the line should break, balance, or follow other wrapping method. It helps in improving the readability of the text.
Syntax
The syntax for the text-wrap property is as follows:
text-wrap: wrap | nowrap | balance | pretty | stable;
Property Values
CSS text-wrap property accepts the following values:
| Value | Description |
|---|---|
| wrap | It is the default value. The text wraps onto the next line when needed. |
| nowrap | It prevents text from wrapping and keeps it on a single line. |
| balance | It balances the text across multiple lines for an even distribution of the words. |
| pretty | It is similar to wrap but uses a smart wrapping method to improve readability by keeping the orphans to a minimum. |
| stable | Preserves line breaks across reflows for consistent text wrapping. |
Wrapping Text Onto Multiple Lines
To wrap text onto multiple lines when the text is overflowing, we use text-wrap: wrap. It is the default value.
Example
Here is an example of how to use the text-wrap property to wrap the text onto multiple lines.
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS text-wrap Property</title>
<style>
.wrap {
width: 200px;
text-wrap: wrap;
border: 1px solid #000;
padding: 10px;
}
</style>
</head>
<body>
<h2>Text Wrap Example</h2>
<p class="wrap">
This text will wrap onto multiple lines when needed.
</p>
</body>
</html>
Prevent Text From Wrapping
To prevent text from wrapping, we use the nowrap value of the text-wrap property.
Example
In this example, we have used the text-wrap: nowrap property to prevent the text from wrapping onto the next line. The text will be displayed in a single line.
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS text-wrap Property</title>
<style>
.nowrap {
width: 200px;
text-wrap: nowrap;
border: 1px solid #000;
padding: 10px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
</style>
</head>
<body>
<h2>No Wrap Example</h2>
<p class="nowrap">
This text stays in a single line and may overflow.
</p>
</body>
</html>
Distribute Text Evenly Across Each Line
To balance the words equally in each line, we use the balance value of the text-wrap property.
Example
The following example demonstrates balanced text wrapping.
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS text-wrap Property</title>
<style>
.balance {
width: 200px;
text-wrap: balance;
border: 1px solid #000;
padding: 10px;
}
</style>
</head>
<body>
<h2>Balanced Text Wrapping Example</h2>
<p class="balance">
This example demonstrates balanced text wrapping.
</p>
</body>
</html>
Improving Readability With pretty
To improve the readability of the text, by keeping the orphans to a minimum pretty value is used.
Example
The following example demonstrates pretty text wrapping.
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS text-wrap Property</title>
<style>
.pretty {
width: 200px;
text-wrap: pretty;
border: 1px solid #000;
padding: 10px;
}
</style>
</head>
<body>
<h2>Pretty Text Wrapping Example</h2>
<p class="pretty">
This method ensures aesthetically pleasing text wrapping.
</p>
</body>
</html>
Maintain Consistent Wrapping
The stable value keeps line breaks stable across changes in layout For this we use the stable value of the text-wrap property.
Example
The following example demonstrates stable text wrapping.
<!DOCTYPE html>
<html lang="en">
<head>
<title>CSS text-wrap Property</title>
<style>
.stable {
width: 200px;
text-wrap: stable;
border: 1px solid #000;
padding: 10px;
}
</style>
</head>
<body>
<h2>Stable Wrapping Example</h2>
<p class="stable">
This text maintains consistent line breaks even when resized.
</p>
</body>
</html>
Supported Browsers
| Property | ![]() |
![]() |
![]() |
![]() |
![]() |
|---|---|---|---|---|---|
| text-wrap | 114 | 114 | 121 | 17.4 | 100 |




