Our volunteers haven't translated this article into Tiếng Việt yet. Join us and help get the job done!
Summary
The hyphens
CSS property tells the browser how to hyphenate words when line-wrapping. You can prevent hyphenation entirely, control when the browser should hyphenate, or let the browser control when to hyphenate.
Hyphenation rules are language-specific. In HTML, the language is determined by the lang
attribute, and 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.
Initial value | manual |
---|---|
Applies to | all elements |
Inherited | yes |
Media | visual |
Computed value | as specified |
Animatable | no |
Canonical order | the unique non-ambiguous order defined by the formal grammar |
Syntax
hyphens: none; hyphens: manual; hyphens: auto; /* Global values */ hyphens: inherit; hyphens: initial; hyphens: unset;
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 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 Suggesting line break opportunities, should be preferred over automatically selecting break points whenever possible.
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 characters 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.
Formal syntax
none | manual | auto
Example
This CSS snippet creates three classes, one for each possible configuration of the hyphens
property.
<ul> <li><code>none</code>: no hyphen; overflow if needed <p lang="en" class="none">An extreme­ly long English word</p> </li> <li><code>manual</code>: hyphen only at &hyphen; or &shy; (if needed) <p lang="en" class="manual">An extreme­ly long English word</p> </li> <li><code>auto</code>: hyphen where the algo is deciding (if needed) <p lang="en" class="auto">An extreme­ly long English word</p> </li> </ul>
p { width: 55px; border: 1px solid black; } p.none { -webkit-hyphens: none; -ms-hyphens: none; hyphens: none; } p.manual { -webkit-hyphens: manual; -ms-hyphens: manual; hyphens: manual; } p.auto { -webkit-hyphens: auto; -ms-hyphens: auto; hyphens: auto; }
Specifications
Specification | Status | Comment |
---|---|---|
CSS Text Level 3 The definition of 'hyphens' in that specification. |
Working Draft | Initial definition |
Browser compatibility
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | 13-webkit[1] | 10.0-ms[3] | No support | 5.1-webkit | |
Hyphenation dictionary for Afrikaans (af, af-*) | No support | 8.0 (8.0) | No support | No support | No support |
Hyphenation dictionary for Bulgarian (bg, bg-*) | No support | 8.0 (8.0) | No support | No support | No support |
Hyphenation dictionary for Catalan (ca, ca-*) | No support | 8.0 (8.0) | 10.0 | No support | 9.1 |
Hyphenation dictionary for Croatian (hr, hr-*) | No support | 8.0 (8.0) | No support | No support | 9.1 |
Hyphenation dictionary for Czech (cs, cs-*) | No support | No support | 10.0 | No support | 9.1 |
Hyphenation dictionary for Danish (da, da-*) | No support | 8.0 (8.0) | 10.0 | No support | 9.1 |
Hyphenation dictionary for Dutch (nl, nl-*) | No support | 8.0 (8.0) | 10.0 | No support | 5.1 |
Hyphenation dictionary for English (en, en-*) | No support | 6.0 (6.0)[4] | 10.0 | No support | 5.1[5] |
Hyphenation dictionary for Esperanto (eo, eo-*) | No support | 8.0 (8.0) | No support | No support | No support |
Hyphenation dictionary for Estonian (et, et-*) | No support | 8.0 (8.0) | No support | No support | No support |
Hyphenation dictionary for Finnish (fi, fi-*) | No support | 8.0 (8.0) | No support | No support | 9.1 |
Hyphenation dictionary for French (fr, fr-*) | No support | 8.0 (8.0) | 10.0 | No support | 5.1 |
Hyphenation dictionary for Galician (gl, gl-*) | No support | 9.0 | No support | No support | No support |
Hyphenation dictionary for German, Traditional Orthography of 1901 (de-1901, de-AT-1901, de-DE-1901) | No support | 8.0 | ? | No support | ? |
Hyphenation dictionary for German, Reformed Orthography of 1996 (de, de-1996, de-DE, de-AT, de-*) | No support | 8.0 | 10.0 | No support | 5.1 |
Hyphenation dictionary for German, Swiss Orthography (de-CH, de-CH-*) | No support | 8.0 | ? | No support | ? |
Hyphenation dictionary for Hungarian (hu, hu-*) | No support | 9.0 | No support | No support | 9.1 |
Hyphenation dictionary for Icelandic (is, is-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Interlingua (ia, ia-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Italian (it, it-*) | No support | 9.0 | 10.0 | No support | 5.1 |
Hyphenation dictionary for Kurmanji (kmr, kmr-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Latin (la, la-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Lithuanian (lt, lt-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Mongolian (mn, mn-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Norwegian (Bokmål) (no, no-*, nb, nb-*) | No support | 8.0 | 10.0 | No support | 9.1 |
Hyphenation dictionary for Norwegian (Nynorsk) (nn, nn-*) | No support | 8.0 | 10.0 | No support | No support |
Hyphenation dictionary for Polish (pl, pl-*) | No support | 31.0 | 10.0 | No support | 9.1 |
Hyphenation dictionary for Portuguese (pt, pt-*) | No support | 8.0[6] | 10.0 | No support | 9.1 |
Hyphenation dictionary for Brazilian Portuguese (pt-BR) | No support | 8.0[6] | 10.0 | No support | No support |
Hyphenation dictionary for Russian (ru, ru-*) | No support | 8.0 | 10.0 | No support | 5.1 |
Hyphenation dictionary for Serbian, Bosnian, Serbo-Croatian (sh, sh-*, sr, sr-*, bs, bs-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Slovenian (sl, sl-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Spanish (es, es-*) | No support | 8.0 | 10.0 | No support | 5.1 |
Hyphenation dictionary for Swedish (sv, sv-*) | No support | 8.0 | 10.0 | No support | 9.1 |
Hyphenation dictionary for Turkish (tr, tr-*) | No support | 9.0 | 10.0 | No support | 9.1 |
Hyphenation dictionary for Ukrainian (uk, uk-*) | No support | 9.0 | No support | No support | 9.1 |
Hyphenation dictionary for Upper Sorbian (hsb, hsb-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for Welsh (cy, cy-*) | No support | 8.0 | No support | No support | No support |
Hyphenation dictionary for other languages | No support | No support | No support | No support | No support |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | 4.0-webkit[1] | 6.0 (6.0)-moz[2] 43.0 (43.0) |
No support | No support | 4.2-webkit |
Hyphenation dictionary for Afrikaans (af, af-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Bulgarian (bg, bg-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Catalan (ca, ca-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Croatian (hr, hr-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Czech (cs, cs-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Danish (da, da-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Dutch (nl, nl-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for English (en, en-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Esperanto (eo, eo-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Estonian (et, et-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Finnish (fi, fi-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for French (fr, fr-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Galician (gl, gl-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for German, Traditional Orthography of 1901 (de-1901, de-AT-1901, de-DE-1901) | ? | ? | ? | ? | ? |
Hyphenation dictionary for German, Reformed Orthography of 1996 (de, de-1996, de-DE, de-AT, de-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for German, Swiss Orthography (de-CH, de-CH-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Hungarian (hu, hu-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Icelandic (is, is-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Interlingua (ia, ia-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Italian (it, it-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Kurmanji (kmr, kmr-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Latin (la, la-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Lithuanian (lt, lt-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Mongolian (mn, mn-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Norwegian (Bokmål) (no, no-*, nb, nb-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Norwegian (Nynorsk) (nn, nn-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Polish (pl, pl-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Portuguese (pt, pt-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Brazilian Portuguese (pt-BR) | ? | ? | ? | ? | |
Hyphenation dictionary for Russian (ru, ru-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Serbian, Bosnian, Serbo-Croatian (sh, sh-*, sr, sr-*, bs, bs-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Slovenian (sl, sl-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Spanish (es, es-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Swedish (sv, sv-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Turkish (tr, tr-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Ukrainian (uk, uk-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Upper Sorbian (hsb, hsb-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for Welsh (cy, cy-*) | ? | ? | ? | ? | ? |
Hyphenation dictionary for other languages | ? | ? | ? | ? | ? |
[1] No automatic hyphenation, only -webkit-hyphens: none
is supported.
[2] Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See the note below for a complete list of such languages.
[3] Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Internet Explorer. See the note below for a complete list of such languages.
[4] Uses an en-US dictionary.
[5] en-GB and en-US used different dictionaries.
[6] Uses a Portuguese dictionary.