CSS’s Word-Wrap Property

CSS’s word-wrap property can be used to break a really long word so that it continues on the next line rather than having the word extend beyond its potential boundaries so that it all stays on one line.

Let’s say you had a really long word that was taking up way too much space, like in the image below:

Join us in our newest publication:

Screen Shot 2017-01-23 at 11.22.58 AM

If you wanted the word to stay within its boundaries (the container that the paragraph is in is only supposed to be 250px wide), you can use the word-wrap property to tell the code that it’s okay to break up the word to keep it contained to the confines of its parent div. Here’s what your CSS would need to look like:

p{
word-wrap: break-word;
}

Now your text should look like this:

Screen Shot 2017-01-23 at 11.23.49 AM

You’ll see that the word is now cut off almost in the middle. This isn’t the default in CSS because it doesn’t always look great, but there are definitely times when you’ll need to use word-wrap property to make sure the text doesn’t overflow and maintain the integrity of your divs.

Share and Enjoy !

0Shares
0 0