Often we need to add custom widgets, div, and tables to our WordPress sites. It is a common issue to find the text or hyperlink is “overflowing” from a desired, defined area degrading the design and pushing towards a “home-made” feel. Correcting these kinds of minute problems makes the total website look professional.
In CSS, if we have an unbreakable string such as an URL or an unusually long word, by default it will overflow whenever the div is too small for it. Look at the sidebar of this website on the right hand side. You’ll find a widget named “About this article” which starts with the text “Cite this article as Abhishek Ghosh…”. There is an URL to the article.
Normally, the link will display as an overflow since showing it in some other way else could cause the vanishing of a part. In this case, overflow is visible, and we can see the overflowing text. If overflow was set to hide, the link would get partially chopped off.
---
I can provide you with can example situation:
1 2 3 4 5 6 7 8 9 | <style> .examplebox { inline-size: 100px; } </style> <div class="examplebox"> Meowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww </div> |
Below is its application:
The overflow-wrap
property can help in this case. The overflow-wrap
property is the same as the property word-wrap
(non-standard). word-break
is an alternate. This word-break
property will break the word at the point it overflows.
The topic is big. All we want is to give you a quick but robust solution.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | <style> .wrapwordexample { white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */ white-space: -pre-wrap; /* Opera 4-6 */ white-space: -o-pre-wrap; /* Opera 7 */ white-space: pre-wrap; /* css-3 */ word-wrap: break-word; /* Internet Explorer 5.5+ */ white-space: -webkit-pre-wrap; /* Newer versions of Chrome/Safari*/ word-break: break-all; white-space: normal; } </style> <div class="wrapwordexample"> <div class="examplebox"> Meowwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwwww </div> <table style="table-layout:fixed; width:400px"> <tr> <td class="wrapwordexample"></td> </tr> </table> </div> |
This is the application:
I hope this solution works for your need.