I've got a span that's 350 pixels wide. If there's more text than that, it just goes straight out to the right off to the side of the span. How do I force the text to wrap down into a paragraph? I've tried a variety of things which I've found on the web, and nothing seems to work.
This needs to work for IE 6 onward. It would be good if it worked in Firefox, too.
UPDATE:
Here's a little more info. I'm trying to implement a tooltip. Here's my code:
HTML
<td style="text-align:left;" nowrap="nowrap" class="t-last"> <a class="htooltip" href="#"> Notes<span style="top: 40px; left: 1167px; "> <ul> <li>Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Maecenas porttitor congue massa. Fusce posuere, magna sed pulvinar ultricies, purus lectus malesuada libero, sit amet commodo magna eros quis urna. Nunc viverra imperdiet enim. Fusce est. Vivamus a tellus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Proin pharetra nonummy pede. Mauris et orci.</li> </ul> </span> </a> </td>
CSS
.htooltip, .htooltip:visited, .tooltip:active { color: #0077AA; text-decoration: none; } .htooltip:hover { color: #0099CC; } .htooltip span { display: inline-block; /*-ms-word-wrap: normal;*/ word-wrap: break-word; background-color: black; color: #fff; padding: 5px 10px 5px 40px; position: absolute; text-decoration: none; visibility: hidden; width: 350px; z-index: 10; } .htooltip:hover span { position: absolute; visibility: visible; }
Syntax: word-wrap: normal|break-word|initial|inherit; Example 1: The following code demonstrates the “normal” value for the word-wrap property. The text is broken which is shown by a border.
Use the textContent property to get the text of a span element, e.g. const text = span. textContent . The textContent property will return the text content of the span and its descendants.
Select the picture or object. Go to Picture Format or Shape Format and select Arrange > Wrap Text. If the window is wide enough, Word displays Wrap Text directly on the Picture Format tab. Choose the wrapping options that you want to apply.
Wrapping can be done in various ways. I'll mention 2 of them:
1.) text wrapping - using white-space property http://www.w3schools.com/cssref/pr_text_white-space.asp
2.) word wrapping - using word-wrap property http://webdesignerwall.com/tutorials/word-wrap-force-text-to-wrap
By the way, in order to work using these 2 approaches, I believe you need to set the "display" property to block of the corresponding span element.
However, as Kirill already mentioned, it's a good idea to think about it for a moment. You're talking about forcing the text into a paragraph. PARAGRAPH. That should ring some bells in your head, shouldn't it? ;)
You should use white-space with display table
Example: legend { display:table; /* Enable line-wrapping in IE8+ */ white-space:normal; /* Enable line-wrapping in old versions of some other browsers */ }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With