make text wrap css
Code snippet for how to make text wrap css with sample and detail explanation
Creating CSS text-wrap can enhance the readability of your website or web application considerably. In this guide, we will walk you through the steps to create CSS text-wrap and explain how it functions.
Code snippet for CSS Text Wrap
Consider the following HTML:
<div class="text_wrap">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Cras convallis nulla et magna vestibulum, at scelerisque ante interdum.
</div>
For applying CSS text-wrap, see the following CSS snippet:
.text_wrap {
word-wrap: break-word;
width: 200px;
}
Code Explanation for CSS Text Wrap
Here is a step by step explanation of the CSS Text Wrap code:
-
div
with classtext_wrap
: This is a block of text on which we want to apply the text wrap. -
word-wrap: break-word
: This CSS property is used to specify whether to break words when the content overflows the boundaries of its container. -
width: 200px
: Defines the width of the container. The text inside thediv
with classtext_wrap
will start wrapping once it reaches this limit.
In conclusion, the word-wrap: break-word;
in the CSS forces the text to wrap onto the next line if it exceeds the specified width of its container, thus preventing overflow. It makes your website or web page layout more appealing and easier to read, improving the overall user experience.