--- title: hyphens slug: Web/CSS/hyphens translation_of: Web/CSS/hyphens ---
{{CSSRef}}

Summary

CSS 属性 hyphens 告知浏览器在换行时如何使用连字符连接单词。可以完全阻止使用连字符,也可以控制浏览器什么时候使用,或者让浏览器决定什么时候使用。

连字规则具有语言特定性。在 HTML 中,语言由 lang 属性决定,浏览器只会在当前属性存在且有合适的连字字典可用的情况使用连字进行连接。 在 XML 中,必须使用 xml:lang 属性。

注意::在规范中,没有明确定义连字符的实现规则,所以具体的连字符在不同浏览器中可能有所区别。

{{cssinfo}}

语法

hyphens: none;
hyphens: manual;
hyphens: auto;

/* Global values */
hyphens: inherit;
hyphens: initial;
hyphens: unset;

none
换行时单词不会被打断,甚至在单词内的字符建议有换行点时。行只会在空白符处换行。
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 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

{{csssyntax}}

示例

以下代码段展示了hyphens属性取none/manual/auto这三类值的效果。

<ul>
  <li><code>none</code>: no hyphen; overflow if needed
    <p lang="en" class="none">An extreme&shy;ly long English word</p>
  </li>
  <li><code>manual</code>: hyphen only at &amp;hyphen; or &amp;shy; (if needed)
    <p lang="en" class="manual">An extreme&shy;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&shy;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;
}

{{EmbedLiveSample("Example", "100%", "470'")}}

Specifications

Specification Status Comment
{{SpecName("CSS3 Text", "#hyphens-property", "hyphens")}} {{Spec2("CSS3 Text")}} Initial definition

Browser compatibility

{{CompatibilityTable}}
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support {{CompatChrome("13")}}{{property_prefix("-webkit")}}[1]

{{CompatGeckoDesktop("6.0")}}{{property_prefix("-moz")}}[2]
{{CompatGeckoDesktop("43.0")}}

{{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.

See also