--- title: hyphens slug: Web/CSS/hyphens translation_of: Web/CSS/hyphens ---
CSS 属性 hyphens
告知浏览器在换行时如何使用连字符连接单词。可以完全阻止使用连字符,也可以控制浏览器什么时候使用,或者让浏览器决定什么时候使用。
连字规则具有语言特定性。在 HTML 中,语言由 lang 属性决定,浏览器只会在当前属性存在且有合适的连字字典可用的情况使用连字进行连接。 在 XML 中,必须使用 xml:lang
属性。
{{cssinfo}}
hyphens: none; hyphens: manual; hyphens: auto; /* Global values */ hyphens: inherit; hyphens: initial; hyphens: unset;
none
manual
auto
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.There are two Unicode characters that can be used to manually specify potential line break points within text:
­
to insert a soft hyphen.以下代码段展示了hyphens
属性取none/manual/auto这三类值的效果。
<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; }
Specification | Status | Comment |
---|---|---|
{{SpecName("CSS3 Text", "#hyphens-property", "hyphens")}} | {{Spec2("CSS3 Text")}} | Initial definition |
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support | {{CompatChrome("13")}}{{property_prefix("-webkit")}}[1] |
{{CompatGeckoDesktop("6.0")}}{{property_prefix("-moz")}}[2] |
{{CompatIE("10.0")}}{{property_prefix("-ms")}}[3] | {{CompatNo}} | {{CompatSafari(5.1)}}{{property_prefix("-webkit")}} |
Hyphenation dictionary for Afrikaans (af, af-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Bulgarian (bg, bg-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Catalan (ca, ca-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Croatian (hr, hr-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Czech (cs, cs-*) | {{CompatNo}} | {{CompatNo}} | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Danish (da, da-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Dutch (nl, nl-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | 10.0 | {{CompatNo}} | 5.1 |
Hyphenation dictionary for English (en, en-*) | {{CompatNo}} | {{CompatGeckoDesktop("6.0")}}[4] | 10.0 | {{CompatNo}} | 5.1[5] |
Hyphenation dictionary for Esperanto (eo, eo-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Estonian (et, et-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Finnish (fi, fi-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for French (fr, fr-*) | {{CompatNo}} | {{CompatGeckoDesktop("8.0")}} | 10.0 | {{CompatNo}} | 5.1 |
Hyphenation dictionary for Galician (gl, gl-*) | {{CompatNo}} | 9.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for German, Traditional Orthography of 1901 (de-1901, de-AT-1901, de-DE-1901) | {{CompatNo}} | 8.0 | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} |
Hyphenation dictionary for German, Reformed Orthography of 1996 (de, de-1996, de-DE, de-AT, de-*) | {{CompatNo}} | 8.0 | 10.0 | {{CompatNo}} | 5.1 |
Hyphenation dictionary for German, Swiss Orthography (de-CH, de-CH-*) | {{CompatNo}} | 8.0 | {{CompatUnknown}} | {{CompatNo}} | {{CompatUnknown}} |
Hyphenation dictionary for Hungarian (hu, hu-*) | {{CompatNo}} | 9.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Icelandic (is, is-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Interlingua (ia, ia-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Italian (it, it-*) | {{CompatNo}} | 9.0 | 10.0 | {{CompatNo}} | 5.1 |
Hyphenation dictionary for Kurmanji (kmr, kmr-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Latin (la, la-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Lithuanian (lt, lt-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Mongolian (mn, mn-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Norwegian (Bokmål) (no, no-*, nb, nb-*) | {{CompatNo}} | 8.0 | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Norwegian (Nynorsk) (nn, nn-*) | {{CompatNo}} | 8.0 | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Polish (pl, pl-*) | {{CompatNo}} | 31.0 | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Portuguese (pt, pt-*) | {{CompatNo}} | 8.0[6] | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Brazilian Portuguese (pt-BR) | {{CompatNo}} | 8.0[6] | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Russian (ru, ru-*) | {{CompatNo}} | 8.0 | 10.0 | {{CompatNo}} | 5.1 |
Hyphenation dictionary for Serbian, Bosnian, Serbo-Croatian (sh, sh-*, sr, sr-*, bs, bs-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Slovenian (sl, sl-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Spanish (es, es-*) | {{CompatNo}} | 8.0 | 10.0 | {{CompatNo}} | 5.1 |
Hyphenation dictionary for Swedish (sv, sv-*) | {{CompatNo}} | 8.0 | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Turkish (tr, tr-*) | {{CompatNo}} | 9.0 | 10.0 | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Ukrainian (uk, uk-*) | {{CompatNo}} | 9.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Upper Sorbian (hsb, hsb-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for Welsh (cy, cy-*) | {{CompatNo}} | 8.0 | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Hyphenation dictionary for other languages | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} | {{CompatNo}} |
Feature | Android | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile |
---|---|---|---|---|---|
Basic support | {{CompatAndroid("4.0")}}{{property_prefix("-webkit")}}[1] | {{CompatGeckoMobile("6.0")}}{{property_prefix("-moz")}}[2] {{CompatGeckoDesktop("43.0")}} |
{{CompatNo}} | {{CompatNo}} | {{CompatSafari(4.2)}}{{property_prefix("-webkit")}} |
Hyphenation dictionary for Afrikaans (af, af-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Bulgarian (bg, bg-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Catalan (ca, ca-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Croatian (hr, hr-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Czech (cs, cs-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Danish (da, da-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Dutch (nl, nl-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for English (en, en-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Esperanto (eo, eo-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Estonian (et, et-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Finnish (fi, fi-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for French (fr, fr-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Galician (gl, gl-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for German, Traditional Orthography of 1901 (de-1901, de-AT-1901, de-DE-1901) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for German, Reformed Orthography of 1996 (de, de-1996, de-DE, de-AT, de-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for German, Swiss Orthography (de-CH, de-CH-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Hungarian (hu, hu-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Icelandic (is, is-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Interlingua (ia, ia-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Italian (it, it-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Kurmanji (kmr, kmr-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Latin (la, la-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Lithuanian (lt, lt-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Mongolian (mn, mn-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Norwegian (Bokmål) (no, no-*, nb, nb-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Norwegian (Nynorsk) (nn, nn-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Polish (pl, pl-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Portuguese (pt, pt-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Brazilian Portuguese (pt-BR) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | |
Hyphenation dictionary for Russian (ru, ru-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Serbian, Bosnian, Serbo-Croatian (sh, sh-*, sr, sr-*, bs, bs-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Slovenian (sl, sl-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Spanish (es, es-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Swedish (sv, sv-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Turkish (tr, tr-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Ukrainian (uk, uk-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Upper Sorbian (hsb, hsb-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for Welsh (cy, cy-*) | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
Hyphenation dictionary for other languages | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} | {{CompatUnknown}} |
[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.