hyphens
Quick Summary for hyphens
The hyphens CSS property specifies how words should be hyphenated when text wraps across multiple lines. It can prevent hyphenation entirely, hyphenate at manually-specified points within the text, or let the browser automatically insert hyphens where appropriate.
Code Usage for hyphens
/* Keyword values */ hyphens: none; hyphens: manual; hyphens: auto;  /* Global values */ hyphens: inherit; hyphens: initial; hyphens: revert; hyphens: unset; 
More Details for hyphens

hyphens

The hyphens CSS property specifies how words should be hyphenated when text wraps across multiple lines. It can prevent hyphenation entirely, hyphenate at manually-specified points within the text, or let the browser automatically insert hyphens where appropriate.

Note: In the above demo, the string "An extraordinarily long English word!" contains the hidden ­ (soft hyphen) character: An extra­ordinarily long English word!. This character is used to indicate a potential place to insert a hyphen when hyphens: manual; is specified.

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 the appropriate hyphenation dictionary is available. In 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.

If supported, hyphenate-character may be used to specify an alternative hyphenation character to use at the end of the line being broken.

Syntax

/* Keyword values */ hyphens: none; hyphens: manual; hyphens: auto;  /* Global values */ hyphens: inherit; hyphens: initial; hyphens: revert; hyphens: unset; 

The hyphens property is specified as a single keyword value chosen from the list below.

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 below for details.

auto

The browser is free to automatically break words at appropriate hyphenation points, following whatever rules it chooses. However, suggested line break opportunities (see Suggesting line break opportunities below) will override automatic break point selection when present.

Note: The auto setting's behavior depends on the language being properly tagged to select the appropriate hyphenation rules. You must specify a language using the lang HTML attribute to guarantee that automatic hyphenation is applied in that language.

Suggesting line break opportunities

There are two Unicode characters 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 marks a place where the browser should break the word if hyphenation is necessary. In HTML, use ­ to insert a soft hyphen.

Note: When the HTML <wbr> element leads to a line break, no hyphen is added.

Formal definition

Initial valuemanual
Applies toall elements
Inheritedyes
Computed valueas specified
Animation typediscrete

Formal syntax

none | manual | auto

Examples

Specifying text hyphenation

This example uses three classes, one for each possible configuration of the hyphens property.

HTML
<dl>   <dt><code>none</code>: no hyphen; overflow if needed</dt>   <dd lang="en" class="none">An extreme&shy;ly long English word</dd>   <dt><code>manual</code>: hyphen only at &amp;hyphen; or &amp;shy; (if needed)</dt>   <dd lang="en" class="manual">An extreme&shy;ly long English word</dd>   <dt><code>auto</code>: hyphens where the algorithm decides (if needed)</dt>   <dd lang="en" class="auto">An extreme&shy;ly long English word</dd> </dl> 
CSS
dd {   width: 55px;   border: 1px solid black;  } dd.none {   -webkit-hyphens: none;   -ms-hyphens: none;   hyphens: none; } dd.manual {   -webkit-hyphens: manual;   -ms-hyphens: manual;   hyphens: manual; } dd.auto {   -webkit-hyphens: auto;   -ms-hyphens: auto;   hyphens: auto; } 
Result

Specifications

Specification
CSS Text Module Level 3 # hyphens-property

See also

content overflow-wrap (formerly word-wrap) word-break Guide to wrapping and breaking text

Last modified: Jan 14, 2022, by MDN contributors

Select your preferred language English (US)DeutschEspañolFrançais日本語한국어Português (do Brasil)Русский中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

Subscribe to weekly updates about things i have added to the site or thought interesting during the last week.

You could also follow me on twitter or not... does anyone even use twitter anymore?

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote

“Make no mistake: This is not your diary. You are not letting it all hang out. You are picking and choosing every single word.”


Dani Shapiro
Random CSS Property

size-adjust

The size-adjust CSS descriptor defines a multiplier for glyph outlines and metrics associated with this font. This makes it easier to harmonize the designs of various fonts when rendered at the same font size.
size-adjust (@font-face) css reference