![]() |
VOOZH | about |
The word-wrap property in CSS is used to manage the breaking and wrapping of long words within an element, ensuring that the content fits within its container. This property is essential for maintaining readability and layout integrity when dealing with lengthy words or strings without spaces. 👁 Image
word-wrap: normal|break-word|initial|inherit;| Value | Description |
|---|---|
normal | Default value; lines can only be broken at normal break points (spaces, non-alphanumeric characters). |
break-word | Words that exceed the width of the container will be arbitrarily broken to fit within the bounds. |
initial | Sets the word-wrap property to its default value. |
inherit | Inherits the property from its parent. |
This example demonstrates the default behavior where words only break at normal break points.
Example: In the example, word-wrap: normal; ensures text in the <div> breaks only at spaces or punctuation, not within words, causing overflow beyond the container's 150px width.
This example shows how words exceeding the container's width are broken to fit within the bounds.
Example: In this example, the word-wrap: break-word; allows the text in the <div> to break arbitrarily within words to fit within the 150px width container.
Output:
By using the word-wrap property, you can control how long words are handled in your layouts, ensuring that content remains within its container and maintaining a clean, readable presentation.
Supported Browsers: The browser supported by word-wrap property are listed below: