CSS Word Wrap


Prev Tutorial Next Tutorial

CSS Word Wrap

CSS Word Wrap properties are used for break the long words and wrap onto the next line. The main use of this properties is to prevent overflow when a long string unable to fit into containing box.

CSS word wrap values

ValueDescription
normalThis property is used to break words only at allowed break points.
break-wordIt is used to break unbreakable words.
initialIt sets this property to its default value.
inheritIt inherits this property from its parent element.

Example without using word-break

In below example we understand what happen when we do not use word-break. Larger word will be display out side the box area

Example

<!DOCTYPE html>  
<html>  
<head>  
<style>  
p.box {  
    width: 140px;  
    background: cyan;   
    border: 1px solid #000000;  
    padding:10px;  
} 
</style>  
</head>  
<body>  
<p class="box">This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?</p>  
</body>  
</html>

Result

This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?.

Example using word-break

Example

<!DOCTYPE html>  
<html>  
<head>  
<style>  
p.box {  
    width: 140px;  
    background: cyan;   
    border: 1px solid #000000;  
    padding:10px;  
    word-wrap: break-word;  
} 
</style>  
</head>  
<body>  
<p class="box">This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?</p>  
</body>  
</html>

Result

This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?.

Browser supported

Properties
word-wrapYesYesYesYesYes

Prev Tutorial Next Tutorial

Google Advertisements
Download Projects

Google Adsense Advertisements

Buy 3 Year Old Domain, Tutorialday.com, SeosmoTools.com @$200

Buy This Ad Space @$50 per Month, Ad Size 300X250 Contact on: hitesh.xc@gmail.com WhatsApp no. 8882538826

Yahoo Advertisements