hyphens

  • Revision slug: CSS/hyphens
  • Revision title: hyphens
  • Revision id: 26637
  • Created:
  • Creator: Bzbarsky
  • Is current revision? No
  • Comment 8 words added, 1 words removed

Revision Content

{{ CSSRef() }}

{{ SeeCompatTable() }}

Summary

The hyphens property tells the browser how to go about splitting words to improve the layout of text when line-wrapping.

Note: The rules defining how hyphenation is performed are not explicitly defined by the specification, so the exact hyphenation may vary from browser to browser.
  • {{ Xref_cssinitial() }}: manual
  • Applies to: all elements
  • {{ Xref_cssinherited() }}: yes
  • Percentages: n/a
  • Media: {{ Xref_cssvisual() }}
  • {{ Xref_csscomputed() }}: as specified

Syntax

hyphens:  none | manual | auto

Values

none
Words are not broken at line breaks, even if characters inside the words suggest line break points. Lines will only wrap at whitespace.
manual
Words are broken for line-wrapping only where characters inside the word suggest line break opportunities. See {{ anch("Suggesting line break opportunities") }} for details.
auto
The browser is free to automatically break words at appropriate hyphenation points, following whatever rules it chooses to use. Suggested line break opportunities, as covered in {{ anch("Suggesting line break opportunities") }}, should be preferred over automatically selecting break points whenever possible.
Note: The auto setting's behavior depends on the language being properly tagged so that the appropriate hyphenation rules can be selected. You must specify a language using the lang HTML attribute in order to guarantee that automatic hyphenation applied in the language of your choice.

Suggesting line break opportunities

There are two Unicode character that can be used to manually specify potential line break points within text:

U+2010 (HYPHEN)
The "hard" hyphen character indicates a visible line break opportunity. Even if the line is not actually broken at that point, the hyphen is still rendered.
U+00AD (SHY)
An invisible, "soft" hyphen. This character is not rendered visibly; instead, it suggests a place where the browser might choose to break the word if necessary. In HTML, you can use ­ to insert a soft hyphen.

Example

This CSS snippet creates three classes, one for each possible configuration of the hyphens property.

p.none {
  -moz-hyphens: none;
  hyphens: none;
}
p.manual {
  -moz-hyphens: manual;
  hyphens: manual;
}
p.auto {
  -moz-hyphens: auto;
  hyphens: auto;
}

Take a look at the live example to see these configurations in action; resize the window while looking at them to see them in action.

{{ CSSLiveSample("hyphens.html") }}

Specifications

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{ CompatUnknown() }}

{{ CompatGeckoDesktop("6.0") }}{{ property_prefix("-moz") }}

Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See this note for a complete list of such languages.

{{ CompatUnknown() }} {{ CompatUnknown() }}

5.1{{ property_prefix("-webkit") }}

Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }}

{{ CompatGeckoMobile("6.0") }}{{ property_prefix("-moz") }}

Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See this note for a complete list of such languages.

{{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatUnknown() }}

Gecko notes

Gecko (Firefox) supplies hyphenation dictionaries for the following languages:

  • Afrikaans (af) {{ gecko_minversion_inline("8.0") }}
  • Bulgarian (bg) {{ gecko_minversion_inline("8.0") }}
  • Catalan (ca) {{ gecko_minversion_inline("8.0") }}
  • Swiss German, Traditional Orthography (de-CH) {{ gecko_minversion_inline("8.0") }}
  • Danish (da) {{ gecko_minversion_inline("8.0") }}
  • Dutch (nl) {{ gecko_minversion_inline("8.0") }}
  • English, United States (en-US) {{ gecko_minversion_inline("6.0") }}
  • Esperanto (eo) {{ gecko_minversion_inline("8.0") }}
  • Estonian (et) {{ gecko_minversion_inline("8.0") }}
  • Finnish (fi) {{ gecko_minversion_inline("8.0") }}
  • French (fr) {{ gecko_minversion_inline("8.0") }}
  • Galician (gl) {{ gecko_minversion_inline("9.0") }}
  • German, Traditional Orthography (de-1901) {{ gecko_minversion_inline("8.0") }}
  • German, Reformed Orthography (de-1996) {{ gecko_minversion_inline("8.0") }}
  • Hungarian (hu) {{ gecko_minversion_inline("9.0") }}
  • Icelandic (is) {{ gecko_minversion_inline("8.0") }}
  • Interlingua (ia) {{ gecko_minversion_inline("8.0") }}
  • Italian (it) {{ gecko_minversion_inline("9.0") }}
  • Kurmanji (kmr) {{ gecko_minversion_inline("8.0") }}
  • Latin (la) {{ gecko_minversion_inline("8.0") }}
  • Lithuanian (lt) {{ gecko_minversion_inline("8.0") }}
  • Mongolian (mn) {{ gecko_minversion_inline("8.0") }}
  • Norwegian Bokmål (nb) {{ gecko_minversion_inline("8.0") }}
  • Norwegian Nynorsk (nn) {{ gecko_minversion_inline("8.0") }}
  • Portuguese (pt) {{ gecko_minversion_inline("8.0") }}
  • Russian (ru) {{ gecko_minversion_inline("8.0") }}
  • Serbo-Croatian (sh) {{ gecko_minversion_inline("8.0") }}
  • Slovenian (sl) {{ gecko_minversion_inline("8.0") }}
  • Spanish (es) {{ gecko_minversion_inline("8.0") }}
  • Swedish (sv) {{ gecko_minversion_inline("8.0") }}
  • Turkish (tr) {{ gecko_minversion_inline("9.0") }}
  • Ukrainian (uk) {{ gecko_minversion_inline("9.0") }}
  • Upper Sorbian (hsb) {{ gecko_minversion_inline("8.0") }}
  • Welsh (cy) {{ gecko_minversion_inline("8.0") }}

See also

{{ Cssxref("content") }}

{{ languages( { "ja": "ja/CSS/hyphens"} ) }}

Revision Source

<p>{{ CSSRef() }}</p>
<p>{{ SeeCompatTable() }}</p>
<h3 name="Summary">Summary</h3>
<p>The <code>hyphens</code> property tells the browser how to go about splitting words to improve the layout of text when line-wrapping.</p>
<div class="note"><strong>Note:</strong> The rules defining how hyphenation is performed are not explicitly defined by the specification, so the exact hyphenation may vary from browser to browser.</div>
<ul> <li>{{ Xref_cssinitial() }}: <code>manual</code></li> <li>Applies to: all elements</li> <li>{{ Xref_cssinherited() }}: yes</li> <li>Percentages: n/a</li> <li>Media: {{ Xref_cssvisual() }}</li> <li>{{ Xref_csscomputed() }}: as specified</li>
</ul>
<h3 name="Syntax">Syntax</h3>
<pre class="eval">hyphens:  none | manual | auto
</pre>
<h3 name="Values">Values</h3>
<dl> <dt><code>none</code></dt> <dd>Words are not broken at line breaks, even if characters inside the words suggest line break points. Lines will only wrap at whitespace.</dd> <dt><code>manual</code></dt> <dd>Words are broken for line-wrapping only where characters inside the word suggest line break opportunities. See {{ anch("Suggesting line break opportunities") }} for details.</dd> <dt><code>auto</code></dt> <dd>The browser is free to automatically break words at appropriate hyphenation points, following whatever rules it chooses to use. Suggested line break opportunities, as covered in {{ anch("Suggesting line break opportunities") }}, should be preferred over automatically selecting break points whenever possible.</dd>
</dl>
<div class="note"><strong>Note:</strong> The <code>auto</code> setting's behavior depends on the language being properly tagged so that the appropriate hyphenation rules can be selected. You must specify a language using the <code>lang</code> HTML attribute in order to guarantee that automatic hyphenation applied in the language of your choice.</div>
<dl>
</dl>
<h3>Suggesting line break opportunities</h3>
<p>There are two Unicode character that can be used to manually specify potential line break points within text:</p>
<dl> <dt>U+2010 (HYPHEN)</dt> <dd>The "hard" hyphen character indicates a visible line break opportunity. Even if the line is not actually broken at that point, the hyphen is still rendered.</dd> <dt>U+00AD (SHY)</dt> <dd>An invisible, "soft" hyphen. This character is not rendered visibly; instead, it suggests a place where the browser might choose to break the word if necessary. In HTML, you can use <code>&amp;shy;</code> to insert a soft hyphen.</dd>
</dl>
<h3 name="Examples">Example</h3>
<p>This CSS snippet creates three classes, one for each possible configuration of the <code>hyphens</code> property.</p>
<pre class="brush: dekiscript">p.none {
  -moz-hyphens: none;
  hyphens: none;
}
p.manual {
  -moz-hyphens: manual;
  hyphens: manual;
}
p.auto {
  -moz-hyphens: auto;
  hyphens: auto;
}
</pre>
<p>Take a look at the live example to see these configurations in action; resize the window while looking at them to see them in action.</p>
<p>{{ CSSLiveSample("hyphens.html") }}</p>
<h3>Specifications</h3>
<ul> <li><a class="external" href="http://www.w3.org/TR/2011/WD-css3-text-20110412/#hyphens" title="http://www.w3.org/TR/2011/WD-css3-text-20110412/#hyphens">CSS 3 Text: hyphens</a></li> <li><a class="external" href="http://www.w3.org/TR/css3-gcpm/#hyphenation" title="http://www.w3.org/TR/css3-gcpm/#hyphenation">CSS 3 Generated content: hyphens</a></li>
</ul>
<h3 name="Browser_compatibility">Browser compatibility</h3>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Chrome</th> <th>Firefox (Gecko)</th> <th>Internet Explorer</th> <th>Opera</th> <th>Safari</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td> <p>{{ CompatGeckoDesktop("6.0") }}{{ property_prefix("-moz") }}</p> <p>Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See <a href="/en/CSS/hyphens#Gecko_notes" title="https://developer.mozilla.org/en/CSS/hyphens#Gecko_notes">this note</a> for a complete list of such languages.</p> </td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td> <p>5.1{{ property_prefix("-webkit") }}<br> <code> </code></p> </td> </tr> </tbody> </table>
</div>
<div id="compat-mobile"> <table class="compat-table"> <tbody> <tr> <th>Feature</th> <th>Android</th> <th>Firefox Mobile (Gecko)</th> <th>IE Mobile</th> <th>Opera Mobile</th> <th>Safari Mobile</th> </tr> <tr> <td>Basic support</td> <td>{{ CompatUnknown() }}</td> <td> <p>{{ CompatGeckoMobile("6.0") }}{{ property_prefix("-moz") }}</p> <p>Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See <a href="/en/CSS/hyphens#Gecko_notes" title="https://developer.mozilla.org/en/CSS/hyphens#Gecko_notes">this note</a> for a complete list of such languages.</p> </td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> <td>{{ CompatUnknown() }}</td> </tr> </tbody> </table>
</div>
<h4>Gecko notes</h4>
<p>Gecko (Firefox) supplies hyphenation dictionaries for the following languages:</p>
<div class="threecolumns"> <ul> <li>Afrikaans (af) {{ gecko_minversion_inline("8.0") }}</li> <li>Bulgarian (bg) {{ gecko_minversion_inline("8.0") }}</li> <li>Catalan (ca) {{ gecko_minversion_inline("8.0") }}</li> <li>Swiss German, Traditional Orthography (de-CH) {{ gecko_minversion_inline("8.0") }}</li> <li>Danish (da) {{ gecko_minversion_inline("8.0") }}</li> <li>Dutch (nl) {{ gecko_minversion_inline("8.0") }}</li> <li>English, United States (en-US) {{ gecko_minversion_inline("6.0") }}</li> <li>Esperanto (eo) {{ gecko_minversion_inline("8.0") }}</li> <li>Estonian (et) {{ gecko_minversion_inline("8.0") }}</li> <li>Finnish (fi) {{ gecko_minversion_inline("8.0") }}</li> <li>French (fr) {{ gecko_minversion_inline("8.0") }}</li> <li>Galician (gl) {{ gecko_minversion_inline("9.0") }}</li> <li>German, Traditional Orthography (de-1901) {{ gecko_minversion_inline("8.0") }}</li> <li>German, Reformed Orthography (de-1996) {{ gecko_minversion_inline("8.0") }}</li> <li>Hungarian (hu) {{ gecko_minversion_inline("9.0") }}</li> <li>Icelandic (is) {{ gecko_minversion_inline("8.0") }}</li> <li>Interlingua (ia) {{ gecko_minversion_inline("8.0") }}</li> <li>Italian (it) {{ gecko_minversion_inline("9.0") }}</li> <li>Kurmanji (kmr) {{ gecko_minversion_inline("8.0") }}</li> <li>Latin (la) {{ gecko_minversion_inline("8.0") }}</li> <li>Lithuanian (lt) {{ gecko_minversion_inline("8.0") }}</li> <li>Mongolian (mn) {{ gecko_minversion_inline("8.0") }}</li> <li>Norwegian Bokmål (nb) {{ gecko_minversion_inline("8.0") }}</li> <li>Norwegian Nynorsk (nn) {{ gecko_minversion_inline("8.0") }}</li> <li>Portuguese (pt) {{ gecko_minversion_inline("8.0") }}</li> <li>Russian (ru) {{ gecko_minversion_inline("8.0") }}</li> <li>Serbo-Croatian (sh) {{ gecko_minversion_inline("8.0") }}</li> <li>Slovenian (sl) {{ gecko_minversion_inline("8.0") }}</li> <li>Spanish (es) {{ gecko_minversion_inline("8.0") }}</li> <li>Swedish (sv) {{ gecko_minversion_inline("8.0") }}</li> <li>Turkish (tr) {{ gecko_minversion_inline("9.0") }}</li> <li>Ukrainian (uk) {{ gecko_minversion_inline("9.0") }}</li> <li>Upper Sorbian (hsb) {{ gecko_minversion_inline("8.0") }}</li> <li>Welsh (cy) {{ gecko_minversion_inline("8.0") }}</li> </ul>
</div>
<h3 name="See_also">See also</h3>
<p>{{ Cssxref("content") }}</p>
<p>{{ languages( { "ja": "ja/CSS/hyphens"} ) }}</p>
Revert to this revision