CSS Word Wrap

Advertisements

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 Advertisment

Buy This Ad Space @$20 per Month, Ad Size 600X200 Contact on: hitesh.xc@gmail.com or 9999595223

Magenet is best Adsense Alternative here we earn $2 for single link, Here we get links ads. Magenet

For Projects 9999595223

Google Advertisements


Buy Websites 9999595223

Buy College Projects with Documentation Contact on whatsapp 9999595223. Contact on: hitesh.xc@gmail.com or 9999595223 Try this Keyword C++ Programs

Advertisements