Soft breaks in HTML text

May 02, 2012 | Posted by: Fredrik | Tags: HTML, Snippet

If you want to hint to the web browser where to break a word when it doesn't fit on the same line there's a nice little thing called soft hyphen, available through ­ (also ­ or ­).


<p>This is an example of a wordthat&shy;shouldbreak in the middle if it doesn't fit on the same line.</p>

The above example will break the made up "wordthatshouldbreak" at the &shy; character if the whole word doesn't fit on the same line, resulting in "wordthat-shouldbreak".

More info about line breaks and hyphenation over at W3's HTML 4.01 Specification.

Comments

comments powered by Disqus