Want to share your CSS expertise with others? Apply to the MDN Fellowship by April 1! http://mzl.la/MDNFellowship

mozilla
Your Search Results

    hyphens

    This is an experimental technology
    Because this technology's specification has not stabilized, check the compatibility table for the proper prefixes to use in various browsers. Also note that the syntax and behavior of an experimental technology is subject to change in future versions of browsers as the spec changes.

    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.

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

    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.

    Syntax

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

    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&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 {
      -moz-hyphens: none;
      hyphens: none;
    }
    p.manual {
      -moz-hyphens: manual;
      hyphens: manual;
    }
    p.auto {
      -moz-hyphens: auto;
      hyphens: auto;
    }
    

    Specifications

    Specification Status Comment
    CSS Text Level 3
    The definition of 'hyphens' in that specification.
    Working Draft  

    Browser compatibility

    Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
    Basic support 13-webkit
    No automatic hyphenation, only -webkit-hyphens: none is supported
    6.0 (6.0)-moz
    Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See this note for a complete list of such languages.
    10.0 -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.
    Not supported 5.1-webkit
    Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
    Basic support 4.0-webkit
    No automatic hyphenation, only -webkit-hyphens: none is supported
    6.0 (6.0)-moz
    Automatic hyphenation only works for languages whose hyphenation dictionaries are integrated in Gecko. See this note for a complete list of such languages.
    Not supported Not supported 4.2-webkit

    Notes on supported languages

    Various browsers supply hyphenation dictionaries for the following languages:

    Locales Language Firefox IE Chrome Opera Safari
    af, af-* Afrikaans 8.0 not supported not supported not supported not supported
    bg, bg-* Bulgarian 8.0 not supported not supported not supported not supported
    ca, ca-* Catalan 8.0 10.0 not supported not supported not supported
    hr, hr-* Croatian 8.0 not supported not supported not supported not supported
    cs, cs-* Czech not supported 10.0 not supported not supported not supported
    da, da-* Danish 8.0 10.0 not supported not supported not supported
    nl, nl-* Dutch 8.0 10.0 not supported not supported not supported
    en, en-* English 6.0
    (use en-US dict)
    10.0 not supported not supported not supported
    eo, eo-* Esperanto 8.0 not supported not supported not supported not supported
    et, et-* Estonian 8.0 not supported not supported not supported not supported
    fi, fi-* Finnish 8.0 not supported not supported not supported not supported
    fr, fr-* French 8.0 10.0 not supported not supported not supported
    gl, gl-* Galician 9.0 not supported not supported not supported not supported
    de-1901, de-AT-1901, de-DE-1901 German, Traditional Orthography of 1901 8.0 ? not supported not supported not supported
    de, de-1996, de-DE, de-AT, de-* German, Reformed Orthography of 1996 8.0 10.0 not supported not supported not supported
    de-CH, de-CH-* German, Swiss Orthography 8.0 ? not supported not supported not supported
    hu, hu-* Hungarian 9.0 not supported not supported not supported not supported
    is, is-* Icelandic 8.0 not supported not supported not supported not supported
    ia, ia-* Interlingua 8.0 not supported not supported not supported not supported
    it, it-* Italian 9.0 10.0 not supported not supported not supported
    kmr, kmr-* Kurmanji 8.0 not supported not supported not supported not supported
    la, la-* Latin 8.0 not supported not supported not supported not supported
    lt, lt-* Lithuanian 8.0 not supported not supported not supported not supported
    mn, mn-* Mongolian 8.0 not supported not supported not supported not supported
    no, no-*, nb, nb-* Norwegian (Bokmål) 8.0 10.0 not supported not supported not supported
    nn, nn-* Norwegian (Nynorsk) 8.0 10.0 not supported not supported not supported
    pl, pl-* Polish 31.0 10.0 not supported not supported not supported
    pt, pt-* Portuguese 8.0
    (use Portuguese dict)
    10.0 not supported not supported not supported
    pt-BR Portuguese (do Brazil) 10.0 not supported not supported not supported
    ru, ru-* Russian 8.0 10.0 not supported not supported not supported
    sh, sh-*, sr, sr-*, bs, bs-* Serbian, Bosnian, Serbo-Croatian 8.0 not supported not supported not supported not supported
    sl, sl-* Slovenian 8.0 not supported not supported not supported not supported
    es, es-* Spanish 8.0 10.0 not supported not supported not supported
    sv, sv-* Swedish 8.0 10.0 not supported not supported not supported
    tr, tr-* Turkish 9.0 10.0 not supported not supported not supported
    uk, uk-* Ukrainian 9.0 not supported not supported not supported not supported
    hsb, hsb-* Upper Sorbian 8.0 not supported not supported not supported not supported
    cy, cy-* Welsh 8.0 not supported not supported not supported not supported
      Others not supported not supported not supported not supported not supported

    See also

    Hide Sidebar