Breaking Overflow Text using CSS3



To break overflow text, use the word-wrap property and set it to the value “break-word”. Following is the code displaying how to break overflow text using CSS3 −

Example

 Live Demo

<!DOCTYPE html>
<html>
<head>
<style>
div {
   font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
   border: 3px solid #3008c0;
}
div.one {
   width: 200px;
   word-wrap: normal;
}
div.two {
   width: 200px;
   word-wrap: break-word;
}
</style>
</head>
<body>
<h1>Div1</h1>
<div class="one">
Lorem ipsum dolor sitametconsecteturadipisicjhbjhgjingelit. Rerum, beatae.
</div>
<h1>Div2</h1>
<div class="two">
Lorem ipsum dolor sitametconsecteturadipisicjhbjhgjingelit. Rerum, beatae.
</div>
</body>
</html>

Output

The above code will produce the following output −


Advertisements