Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In HTML, is it possible to insert a word wrapping hint?

Imagine I have a long, multi-word line of text in a DIV:

Hello there, dear customer. Please have a look at our offer.

The DIV has a dynamic width. I want to word wrap the above text. Currently, the wrapping happens on a word boundary which maximizes the length of the first line:

|-DIV WIDTH------------------------------------| Hello there, dear customer. Please have a look at our offer. 

I would prefer that the wrapping happen on the sentence boundary. However, if no wrapping is necessary, I would like the line to remain as one.

To illustrate my point, please look at the various DIV widths and how I would like my text to wrap:

|-DIV WIDTH--------------------------------------------------------| Hello there, dear customer. Please have a look at our offer. |-DIV WIDTH-----------------------------------| Hello there, dear customer.  Please have a look at our offer. |-DIV WIDTH--------| Hello there, dear  customer.  Please have a look at our offer. 

With words, you can use a soft hyphen so that the word wrapping happens on suggested syllable boundaries. If no wrapping is needed, the ­ remains invisible. If wrapping is needed, the ­ is where it happens:

magnifi­cently 

Is there an analogous method for hinting word-wrapping in HTML?

like image 309
Krystian Cybulski Avatar asked Apr 19 '12 10:04

Krystian Cybulski


People also ask

What is wrapping in HTML?

Definition and Usage The wrap attribute specifies how the text in a text area is to be wrapped when submitted in a form.

Which attribute of the tag is used to turn off the word wrapping?

HTML | <td> nowrap Attribute The HTML <td> nowrap Attribute is used to specify that the content present inside the cell should not wrap. It contains the Boolean value.


1 Answers

Use &shy; in words or <wbr> between words, as <wbr> won't introduce a hyphen.

See also:

  • quirksmode: <wbr> compat list
like image 77
Zeta Avatar answered Oct 14 '22 07:10

Zeta