A soft hyphen (­
) indicates where an optional word break may occur. When a soft hyphen breaks a word between one line and the next, a hyphen character is displayed at the end of the first line. When a soft hyphen does not break a word between lines, the hyphen must not be displayed.
Soft hyphens are vital for text that must be displayed on a tiny screen or in a narrow frame. Web browsers have no excuse for rendering them incorrectly, when they can be minimally compliant by ignoring them completely.
Although technically, the ­
character entity was defined in HTML 3.2, I’ll treat soft hyphens as a new feature of HTML 4.0. Until HTML 4.0 explicitly spelled out how they should work, soft hyphens had ambiguous semantics and a history of contradictory interpretations.
In addition to the soft hyphen, there is also a hard hyphen (‐
or ‐
) which always renders, and a nonbreaking hyphen character (‑
or ‑
), for hyphens that do not break words across lines.
For the following test, you may have to resize your screen or window so that a hyphenated word could be broken at the end of a line. (Widths of 80 columns and 640 pixels worked in local testing.)
Line breaks have been added to the above source for readability. The sample below consists of a single line.
the longest real word in the Oxford English Dictionary, dismissing the 45‐letter pneumonoultramicroscopicsilicovolcanoconiosis as
the longest made‑up word in the Oxford English Dictionary.
Related Mozilla bug reports: shy.
HTML 4.0 has named entities for three fixed‐width spaces: the en space, the em space, and the thin space. Unlike ordinary spaces, which may vary in width when text is justified, the en, em, and thin spaces should not change in width.
The fixed‐width spaces are not white space characters, so two of them in sequence should not collapse into a single space. They should not be replaced by line breaks at the end of the line, though line breaks may occur immediately after them.
Line breaks have been added above for readability.
Long lines usually wrap at spaces between words, but in languages without spaces between words (like Thai), sentences may appear as if they were one continuous word.
Zero‐width spaces put “invisible spaces” between words where they can wrap to the next line.[1]. Zero‐width spaces divide long sequences of characters into smaller units that may wrap from one line to the next.
HTML 4.0 lacks a character entity name like &zws;
, so we must use a numeric reference like ​
or ​
. (MathML uses the entity name ​
for this character.)
Zero‐width spaces function similarly to the proprietary <wbr>
word break element in early versions of Netscape.
[1] Invisible in theory, anyway. Some Web browsers display zero‐width spaces as a visible unknown‐character glyph, which is technically not incorrect. Perhaps a future version of the standard will mandate how zero‐width spaces should be rendered, as HTML 4.0 does with soft hyphens.
The following sentence contains a very long number, in which I’ve helpfully included zero‐width spaces every 5 digits. In a visual Web browser that doesn’t treat zero‐width spaces as white space, this page will probably scroll horizontally.
Line breaks have been added to the above source for readability. The sample below consists of a single line.
Related Mozilla bug reports: zws.
Related Konqueror bug reports: #29575.
In Arabic scripts, individual characters join with following ones. However, sometimes Web browsers must be informed to join characters that normally do not, or not to join characters that normally do.
The ‌
entity prevents joining where joining would occur, but should not. The ‍
entity forces joining when it would not occur, but should.
Here is an example of ‍
and ‌
being used with Devanagari characters.
क् + त = क्त (a glyph of kta)
क् + ‍ + त = क्त (half‐ka and ta)
क् + ‌ + त = क्त (ka‐halant and ta)
Related Mozilla bug reports: #202352.
In English‐language text, ‍
may be used to form ligatures.
The MacOS character sets contains ligatures for “fi” and “fl”. Many fonts developed for both MacOS and Microsoft Windows contain the five main f‐ligatures.
Ligature | Entity | Character |
---|---|---|
ff | ff | ff |
fi | fi | fi |
fl | fl | fl |
ffi | ffi | ffi |
ffl | ffl | ffl |
st | st | st |
However, using these character numbers with a typeface that does not support them could result in unknown‐character glyphs. Instead, you could request these ligatures with zero‐width joiners, allowing Web browsers that cannot generate them to gracefully degrade to unjoined characters.
Zero‐width joiners may also request ligatures without official characters in Unicode. Germanic typefaces sometimes have traditional ligatures for “ch”, “ck”, and “tz”. Adobe makes some fancy OpenType fonts with ligatures for “fj”, “ffj”, “Th”, “ct”, and “sp”.
Using ‍
to form ligatures in Latin text is controversial. Some think ‍
should be used for ligatures only in contexts that absolutely require them, and consider it an abuse to request ligatures when unjoined letters convey the same meaning.
The following text requests the five main f‐ligatures. Your Web browser should either join the letters, or gracefully degrade by rendering them as separate letters. The zero‐width joiner itself should always be invisible.
Related Mozilla bug reports: Ligatures.
Your Web browser identified itself as Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko; compatible; ClaudeBot/1.0; +claudebot@anthropic.com)
when it requested this page. Mozilla 5.0
, why do you lie to me so?