hyphens

  • Revision slug: Web/CSS/hyphens
  • Revision title: hyphens
  • Revision id: 394481
  • Created:
  • Creator: Sheppy
  • Is current revision? No
  • Comment Moved From CSS/hyphens to Web/CSS/hyphens

Revision Content

{{CSSRef}}{{SeeCompatTable}}

Summary

The hyphens CSS property tells the browser how to go about splitting words to improve the layout of text when line-wrapping. On HTML, the language is determined by the lang attribute: browsers will hyphenate only if this attribute is present and if an appropriate hyphenation dictionary is available. On XML, the xml:lang attribute must be used.

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.

{{cssbox("hyphens")}}

Syntax

Formal syntax: {{csssyntax("hyphens")}}
hyphens: none
hyphens: manual
hyphens: auto

hyphens: inherit

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 is 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 how hyphenation is handled in your browser.

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

Specifications

Specification Status Comment
{{SpecName('CSS3 Text', '#hyphens', 'hyphens')}} {{Spec2('CSS3 Text')}}  

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 13{{property_prefix("-webkit")}} {{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.
{{CompatIE("10.0")}} {{property_prefix("-ms")}}
Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Internet Explorer. See this note for a complete list of such languages.<
{{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}}

Languages support notes

Various browsers supplies hyphenation dictionaries for the following languages:

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

See also

  • {{Cssxref("content")}}

Revision Source

<div>
  {{CSSRef}}{{SeeCompatTable}}</div>
<h2 id="Summary" name="Summary">Summary</h2>
<p>The <code>hyphens</code> <a href="/en-US/docs/CSS" title="CSS">CSS</a> property tells the browser how to go about splitting words to improve the layout of text when line-wrapping. On HTML, the language is determined by the <code>lang</code> attribute: browsers will hyphenate only if this attribute is present and if an appropriate hyphenation dictionary is available. On XML, the <code>xml:lang</code> attribute must be used.</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>
<p>{{cssbox("hyphens")}}</p>
<h2 id="Syntax" name="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("hyphens")}}
</pre>
<pre>
hyphens: none
hyphens: manual
hyphens: auto

hyphens: inherit
</pre>
<h3 id="Values" 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&nbsp;attribute in order to guarantee that automatic hyphenation is applied in the language of your choice.</div>
<dl>
</dl>
<h2 id="Suggesting_line_break_opportunities">Suggesting line break opportunities</h2>
<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"&nbsp;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>
<h2 id="Examples" name="Examples">Example</h2>
<p>This CSS snippet creates three classes, one for each possible configuration of the <code>hyphens</code> property.</p>
<pre class="brush: css">
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 how hyphenation is handled in your browser.</p>
<p>{{CSSLiveSample("hyphens.html")}}</p>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
  <thead>
    <tr>
      <th scope="col">Specification</th>
      <th scope="col">Status</th>
      <th scope="col">Comment</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>{{SpecName('CSS3 Text', '#hyphens', 'hyphens')}}</td>
      <td>{{Spec2('CSS3 Text')}}</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="Browser_compatibility" name="Browser_compatibility">Browser compatibility</h2>
<div>
  {{CompatibilityTable}}</div>
<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>13{{property_prefix("-webkit")}}</td>
        <td>{{CompatGeckoDesktop("6.0")}}{{property_prefix("-moz")}}<br />
          Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See <a href="/en-US/docs/CSS/hyphens#Languages_support_notes" title="CSS/hyphens#Languages_support_notes">this note</a> for a complete list of such languages.</td>
        <td>{{CompatIE("10.0")}} {{property_prefix("-ms")}}<br />
          Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Internet Explorer. See <a href="/en-US/docs/CSS/hyphens#Languages_support_notes" title="CSS/hyphens#Languages_support_notes">this note</a> for a complete list of such languages.&lt;</td>
        <td>{{CompatUnknown}}</td>
        <td>5.1{{property_prefix("-webkit")}}</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>{{CompatGeckoMobile("6.0")}}{{property_prefix("-moz")}}<br />
          Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See <a href="/en-US/docs/CSS/hyphens#Gecko_notes" title="https://developer.mozilla.org/en/CSS/hyphens#Gecko_notes">this note</a> for a complete list of such languages.</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
        <td>{{CompatUnknown}}</td>
      </tr>
    </tbody>
  </table>
</div>
<h4 id="Languages_support_notes">Languages support notes</h4>
<p>Various browsers supplies hyphenation dictionaries for the following languages:</p>
<table class="standard-table">
  <tbody>
    <tr>
      <th>Language</th>
      <th>Firefox</th>
      <th>IE</th>
    </tr>
    <tr>
      <td>Afrikaans (af)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Bulgarian (bg)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Catalan (ca)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Czech</td>
      <td>&nbsp;</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Swiss German, Traditional&nbsp;Orthography (de-CH)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Danish (da)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Dutch (nl)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>English (en)</td>
      <td>??</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>English, United States (en-US)</td>
      <td>6.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Esperanto (eo)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Estonian (et)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Finnish (fi)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>French (fr)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Galician (gl)</td>
      <td>9.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>German, Traditional&nbsp;Orthography (de-1901)</td>
      <td>8.0</td>
      <td>??</td>
    </tr>
    <tr>
      <td>German, Reformed Orthography (de-1996)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Hungarian (hu)</td>
      <td>9.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Icelandic (is)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Interlingua (ia)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Italian (it)</td>
      <td>9.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Kurmanji (kmr)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Latin (la)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Lithuanian (lt)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Mongolian (mn)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Norwegian Bokmål (nb)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Norwegian Nynorsk (nn)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Polish</td>
      <td>&nbsp;</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Portuguese (pt)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Brazilian Portuguese</td>
      <td>&nbsp;</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Russian (ru)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Serbo-Croatian (sh)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Slovenian (sl)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Spanish (es)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Swedish (sv)</td>
      <td>8.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Turkish (tr)</td>
      <td>9.0</td>
      <td>10.0</td>
    </tr>
    <tr>
      <td>Ukrainian (uk)</td>
      <td>9.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Upper Sorbian (hsb)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
    <tr>
      <td>Welsh (cy)</td>
      <td>8.0</td>
      <td>&nbsp;</td>
    </tr>
  </tbody>
</table>
<h2 id="See_also" name="See_also">See also</h2>
<ul>
  <li>{{Cssxref("content")}}</li>
</ul>
Revert to this revision