overflow-wrap
Quick Summary for word-wrap
The overflow-wrap CSS property applies to inline elements, setting whether the browser should insert line breaks within an otherwise unbreakable string to prevent text from overflowing its line box.
Code Usage for word-wrap
/* Keyword values */ overflow-wrap: normal; overflow-wrap: break-word; overflow-wrap: anywhere;  /* Global values */ overflow-wrap: inherit; overflow-wrap: initial; overflow-wrap: revert; overflow-wrap: unset; 
More Details for word-wrap

overflow-wrap

The overflow-wrap CSS property applies to inline elements, setting whether the browser should insert line breaks within an otherwise unbreakable string to prevent text from overflowing its line box.

Note: In contrast to word-break, overflow-wrap will only create a break if an entire word cannot be placed on its own line without overflowing.

The property was originally a nonstandard and unprefixed Microsoft extension called word-wrap, and was implemented by most browsers with the same name. It has since been renamed to overflow-wrap, with word-wrap being an alias.

Syntax

/* Keyword values */ overflow-wrap: normal; overflow-wrap: break-word; overflow-wrap: anywhere;  /* Global values */ overflow-wrap: inherit; overflow-wrap: initial; overflow-wrap: revert; overflow-wrap: unset; 

The overflow-wrap property is specified as a single keyword chosen from the list of values below.

Values

normal

Lines may only break at normal word break points (such as a space between two words).

anywhere

To prevent overflow, an otherwise unbreakable string of characters — like a long word or URL — may be broken at any point if there are no otherwise-acceptable break points in the line. No hyphenation character is inserted at the break point. Soft wrap opportunities introduced by the word break are considered when calculating min-content intrinsic sizes.

break-word

The same as the anywhere value, with normally unbreakable words allowed to be broken at arbitrary points if there are no otherwise acceptable break points in the line, but soft wrap opportunities introduced by the word break are NOT considered when calculating min-content intrinsic sizes.

Formal definition

Initial valuenormal
Applies tonon-replaced inline elements
Inheritedyes
Computed valueas specified
Animation typediscrete

Formal syntax

normal | break-word | anywhere

Examples

Comparing overflow-wrap, word-break, and hyphens

This example compares the results of overflow-wrap, word-break, and hyphens when breaking up a long word.

HTML
<p>They say the fishing is excellent at   Lake <em class="normal">Chargoggagoggmanchauggagoggchaubunagungamaugg</em>,   though I've never been there myself. (<code>normal</code>)</p> <p>They say the fishing is excellent at   Lake <em class="ow-anywhere">Chargoggagoggmanchauggagoggchaubunagungamaugg</em>,   though I've never been there myself. (<code>overflow-wrap: anywhere</code>)</p> <p>They say the fishing is excellent at   Lake <em class="ow-break-word">Chargoggagoggmanchauggagoggchaubunagungamaugg</em>,   though I've never been there myself. (<code>overflow-wrap: break-word</code>)</p> <p>They say the fishing is excellent at   Lake <em class="word-break">Chargoggagoggmanchauggagoggchaubunagungamaugg</em>,   though I've never been there myself. (<code>word-break</code>)</p> <p>They say the fishing is excellent at   Lake <em class="hyphens">Chargoggagoggmanchauggagoggchaubunagungamaugg</em>,   though I've never been there myself. (<code>hyphens</code>, without <code>lang</code> attribute)</p> <p lang="en">They say the fishing is excellent at   Lake <em class="hyphens">Chargoggagoggmanchauggagoggchaubunagungamaugg</em>,   though I've never been there myself. (<code>hyphens</code>, English rules)</p> <p class="hyphens" lang="de">They say the fishing is excellent at   Lake <em class="hyphens">Chargoggagoggmanchauggagoggchaubunagungamaugg</em>,   though I've never been there myself. (<code>hyphens</code>, German rules)</p> 
CSS
p {    width: 13em;    margin: 2px;    background: gold; }  .ow-anywhere {    overflow-wrap: anywhere; }  .ow-break-word {    overflow-wrap: break-word; }  .word-break {    word-break: break-all; }  .hyphens {    hyphens: auto; } 
Result

Specifications

Specification
CSS Text Module Level 3 # overflow-wrap-property

See also

word-break hyphens text-overflow Guide to wrapping and breaking text

Last modified: Aug 12, 2021, by MDN contributors

Select your preferred language English (US)DeutschFrançais日本語한국어Português (do Brasil)Русский中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote

"Olivia, my eldest daughter, caught measles when she was seven years old. As the illness took its usual course I can remember reading to her often in bed and not feeling particularly alarmed about it. Then one morning, when she was well on the road to recovery, I was sitting on her bed showing her how to fashion little animals out of coloured pipe-cleaners, and when it came to her turn to make one herself, I noticed that her fingers and her mind were not working together and she couldn’t do anything. 'Are you feeling all right?' I asked her. 'I feel all sleepy,' she said. In an hour, she was unconscious. In twelve hours she was dead. The measles had turned into a terrible thing called measles encephalitis and there was nothing the doctors could do to save her. That was...in 1962, but even now, if a child with measles happens to develop the same deadly reaction from measles as Olivia did, there would still be nothing the doctors could do to help her. On the other hand, there is today something that parents can do to make sure that this sort of tragedy does not happen to a child of theirs. They can insist that their child is immunised against measles. ...I dedicated two of my books to Olivia, the first was ‘James and the Giant Peach’. That was when she was still alive. The second was ‘The BFG’, dedicated to her memory after she had died from measles. You will see her name at the beginning of each of these books. And I know how happy she would be if only she could know that her death had helped to save a good deal of illness and death among other children."

I just checked google books for BFG, and the dedication is there. 

https://www.google.com.au/books/edition/_/quybcXrFhCIC?hl=en&gbpv=1 


Roald Dahl, 1986
Random CSS Property

grid-template-columns

The grid-template-columns CSS property defines the line names and track sizing functions of the grid columns.
grid-template-columns css reference