CSS hyphenate-character Property
The CSS hyphenate-character property specifies the character or string displayed at the end of a line when a word is broken at a hyphenation opportunity.
By default, browsers typically display a hyphen when a word is divided between lines. This property allows you to replace that marker with another character or string. It works with the hyphens property, which controls whether and how words may be hyphenated.
hyphenate-character Syntax
The hyphenate-character property accepts the keyword auto or a CSS string containing the desired hyphenation marker.
Basic Syntax
selector {
hyphenate-character: auto;
}
Use a Standard Hyphen
p {
hyphenate-character: "-";
}
Use a Unicode Hyphen
p {
hyphenate-character: "\2010";
}
Use a Custom Character
p {
hyphenate-character: "•";
}
Use a Custom String
p {
hyphenate-character: "--";
}
Use an Empty String
p {
hyphenate-character: "";
}
CSS-Wide Keywords
p {
hyphenate-character: initial;
}
p {
hyphenate-character: inherit;
}
p {
hyphenate-character: unset;
}
p {
hyphenate-character: revert;
}
p {
hyphenate-character: revert-layer;
}
Custom characters and strings must be enclosed in quotation marks. The property does not accept an unquoted character as a replacement marker.
Property Values
The property has two main value types: auto and a CSS string.
| Value | Description |
|---|---|
auto |
Allows the browser to select an appropriate hyphenation marker based on language and typographic conventions. |
<string> |
Specifies the character or string to display at a hyphenation break. |
initial |
Resets the property to auto. |
inherit |
Inherits the computed value from the parent element. |
unset |
Inherits the parent's value because the property is inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | auto |
| Inherited | Yes |
| Applies to | All elements |
| Computed value | As specified |
| Animation type | Discrete |
| Percentages | Not applicable |
| Related properties | hyphens, hyphenate-limit-chars, overflow-wrap, word-break |
The property controls the marker used at hyphenation breaks. It does not independently determine where a word may be divided.
How It Works
When a browser breaks a word at an allowed hyphenation point, it may display a hyphenation marker at the end of the first line.
Default Hyphenation Marker
p {
hyphens: auto;
hyphenate-character: auto;
}
The browser chooses the marker according to its language and typography rules. In English, this is usually a hyphen.
Custom Hyphenation Marker
p {
hyphens: auto;
hyphenate-character: "•";
}
When an eligible word is hyphenated, the custom marker is displayed at the break instead of the browser's default marker.
The Original Word Remains Unchanged
Hyphenation affects the visual presentation of text. The browser does not permanently insert the replacement character into the underlying word.
Important Consideration
The property does not guarantee that a word will be hyphenated. A visible effect requires an actual hyphenation break, and automatic hyphenation depends on language support and the browser's line-breaking decisions.
Automatic Hyphenation
Automatic hyphenation allows the browser to divide words at language-appropriate locations when the available line width is insufficient.
Enable Automatic Hyphenation
.article-text {
hyphens: auto;
hyphenate-character: auto;
}
Use a Custom Marker
.article-text {
hyphens: auto;
hyphenate-character: "\2010";
}
HTML Language Attribute
<p lang="en" class="article-text">
Responsive typography can improve the readability of narrow text columns.
</p>
The lang attribute identifies the language so the browser can apply an appropriate hyphenation dictionary when one is available.
Constrain the Text Width
.article-text {
max-width: 18rem;
hyphens: auto;
hyphenate-character: "-";
}
Narrower text containers make hyphenation opportunities more likely, but the browser still determines whether a word needs to break.
Important Consideration
Automatic hyphenation is not guaranteed for every language or browser. The presence of hyphens: auto does not ensure that all long words will be divided.
Custom Hyphenation Characters
A CSS string can replace the default hyphenation marker with another visible character or sequence.
Standard Hyphen-Minus
p {
hyphenate-character: "-";
}
Unicode Hyphen
p {
hyphenate-character: "\2010";
}
The Unicode character U+2010 is a hyphen. Its appearance may differ slightly from the standard hyphen-minus character.
Bullet Character
p {
hyphenate-character: "•";
}
Multiple Characters
p {
hyphenate-character: "--";
}
No Visible Marker
p {
hyphenate-character: "";
}
An empty string requests no visible replacement marker at the hyphenation break.
Important Consideration
Custom markers should remain easy to understand. Unusual characters may make divided words harder to read, especially in longer paragraphs.
The chosen font must also support the character. If a glyph is unavailable, the browser may use a fallback font or display a replacement symbol.
Soft Hyphens
A soft hyphen identifies an optional word-breaking position within the text. It is normally invisible unless the browser breaks the word at that position.
HTML Soft Hyphen Entity
<p>inter­nationalization</p>
The ­ entity inserts a soft hyphen opportunity between inter and nationalization.
Style the Hyphenation Marker
p {
hyphens: manual;
hyphenate-character: "\2010";
}
With manual hyphenation, the browser may break at the soft hyphen and display the specified marker.
HTML Example
<p lang="en" class="manual-hyphenation">
inter­nationalization
</p>
CSS Example
.manual-hyphenation {
width: 8rem;
hyphens: manual;
hyphenate-character: "-";
}
Important Consideration
A soft hyphen is part of the text's markup or character data, while hyphenate-character is a CSS presentation rule. They serve different purposes.
Some browsers may handle custom hyphenation markers at manual break points differently. Test the intended behavior before relying on it.
Language Support
Automatic hyphenation relies on language-specific rules. Browsers may use dictionaries or other language resources to identify valid word-breaking positions.
English Text
<p lang="en">
Internationalization and accessibility are important parts of web development.
</p>
German Text
<p lang="de">
Die Internationalisierung verbessert die Benutzerfreundlichkeit.
</p>
Apply a Shared Style
.article-text {
hyphens: auto;
hyphenate-character: auto;
}
Override the Marker
.article-text.custom-marker {
hyphenate-character: "\2010";
}
Important Consideration
The CSS property does not select a hyphenation dictionary. Use the HTML lang attribute to identify the text's language.
Different languages have different hyphenation conventions. A custom marker suitable for one language may not be appropriate for another.
Relationship with hyphens
The hyphens property determines whether words may be divided at hyphenation opportunities. The hyphenate-character property controls the marker displayed when such a break occurs.
Disable Hyphenation
p {
hyphens: none;
hyphenate-character: "*";
}
The custom marker has no visible effect because hyphenation is disabled.
Manual Hyphenation
p {
hyphens: manual;
hyphenate-character: "-";
}
Words may break at explicitly provided opportunities, such as soft hyphens.
Automatic Hyphenation
p {
hyphens: auto;
hyphenate-character: "\2010";
}
The browser may use language-specific rules to identify additional hyphenation opportunities.
Comparison
| Property | Purpose |
|---|---|
hyphens |
Controls whether manual or automatic hyphenation opportunities may be used. |
hyphenate-character |
Controls the string displayed when a word breaks at a hyphenation opportunity. |
Important Consideration
Setting hyphenate-character does not automatically enable hyphenation. Use an appropriate hyphens value when configuring the complete behavior.
Hyphenation Limits
Hyphenation can improve line wrapping, but excessive word division may reduce readability. The hyphenate-limit-chars property provides additional control over eligible word lengths and break positions.
Set Character Limits
.article-text {
hyphens: auto;
hyphenate-character: "-";
hyphenate-limit-chars: 6 3 2;
}
This requests a minimum word length of six characters, at least three characters before a hyphenation break, and at least two characters after it.
Use Automatic Limits
.article-text {
hyphens: auto;
hyphenate-limit-chars: auto;
}
Important Consideration
The hyphenate-limit-chars property does not change the visible hyphenation marker. It restricts where hyphenation is permitted.
Support for hyphenation controls varies across browsers. Check compatibility when combining advanced hyphenation properties.
Responsive Text
Hyphenation is especially useful in narrow text columns where long words can create uneven spacing or overflow.
Narrow Text Column
.article-text {
max-width: 20rem;
hyphens: auto;
hyphenate-character: auto;
}
Mobile Layout
@media (max-width: 600px) {
.article-text {
hyphens: auto;
hyphenate-character: "-";
}
}
Use with overflow-wrap
.article-text {
hyphens: auto;
hyphenate-character: "-";
overflow-wrap: break-word;
}
The overflow-wrap property can provide additional emergency break opportunities for text that would otherwise overflow. These emergency breaks are not necessarily hyphenation breaks and do not automatically receive the custom marker.
Important Consideration
Do not rely on custom hyphenation markers to prevent all text overflow. Long URLs, code fragments, and unbroken strings may require separate wrapping rules.
Inheritance
The hyphenate-character property is inherited. Descendant elements receive the parent's computed value unless another value is specified.
Apply to an Article
article {
hyphens: auto;
hyphenate-character: "\2010";
}
Override a Paragraph
article .special-text {
hyphenate-character: "*";
}
Explicit Inheritance
blockquote {
hyphenate-character: inherit;
}
Reset to the Initial Value
blockquote {
hyphenate-character: initial;
}
Reset with unset
blockquote {
hyphenate-character: unset;
}
Because the property is inherited, unset behaves like inherit rather than resetting to auto.
Important Consideration
When applying a custom marker to a large container, remember that nested text elements may inherit it. Override the property where a different typographic treatment is required.
hyphenate-character Example
This example compares the browser's automatic hyphenation marker with a custom marker. The paragraphs use narrow columns to encourage word wrapping. Actual hyphenation depends on browser support, language rules, and available space.
HTML Example
<div class="hyphenate-character-demo">
<div class="demo-panel">
<h3>Default Marker</h3>
<p lang="en" class="default-marker">
Internationalization and accessibility improve website usability.
</p>
</div>
<div class="demo-panel">
<h3>Custom Marker</h3>
<p lang="en" class="custom-marker">
Internationalization and accessibility improve website usability.
</p>
</div>
</div>
CSS Example
.hyphenate-character-demo {
display: flex;
flex-wrap: wrap;
gap: 20px;
}
.hyphenate-character-demo .demo-panel {
width: 160px;
max-width: 100%;
padding: 12px;
border: 1px solid #cccccc;
border-radius: 4px;
}
.hyphenate-character-demo h3 {
margin: 0 0 10px;
font-size: 1rem;
}
.hyphenate-character-demo p {
margin: 0;
hyphens: auto;
line-height: 1.6;
}
.hyphenate-character-demo .default-marker {
hyphenate-character: auto;
}
.hyphenate-character-demo .custom-marker {
hyphenate-character: "•";
}
Default Marker
Internationalization and accessibility improve website usability.
Custom Marker
Internationalization and accessibility improve website usability.
When automatic hyphenation occurs and the browser supports hyphenate-character, the second paragraph displays a bullet at the hyphenation break instead of the default marker.
If no difference appears, the browser may not support the custom marker, or the text may not have been hyphenated.
Use a Standard Hyphen Instead
.hyphenate-character-demo .custom-marker {
hyphenate-character: "-";
}
This variation uses a standard hyphen-minus character as the replacement marker.
Use a Unicode Hyphen
.hyphenate-character-demo .custom-marker {
hyphenate-character: "\2010";
}
This variation uses the Unicode hyphen character, which may have different font metrics from the standard hyphen-minus.
Common Mistakes
Expecting the Property to Enable Hyphenation
p {
hyphenate-character: "*";
}
This declaration changes the marker only when a hyphenation break occurs. It does not independently enable automatic hyphenation.
Using an Unquoted Character
p {
hyphenate-character: *;
}
A custom marker must be a CSS string enclosed in quotation marks.
Forgetting the Language Attribute
Automatic hyphenation may not work as expected when the browser cannot identify the text's language. Use an appropriate HTML lang attribute.
Expecting Every Word to Break
Browsers apply language-specific hyphenation rules and line-breaking constraints. Not every word contains a permitted break point.
Confusing Hyphenation with Emergency Wrapping
Breaks created by overflow-wrap or other emergency wrapping behavior are not necessarily hyphenation breaks and may not display the specified marker.
Using Unusual Markers Without Testing
Custom symbols may reduce readability or display differently across fonts and browsers.
Assuming Identical Browser Behavior
Support for custom hyphenation markers and language-specific hyphenation varies. Test the intended result in the browsers your site supports.
Important Considerations
Keep the following points in mind when using hyphenate-character:
- The property controls the marker displayed at hyphenation breaks.
- The initial value is
auto. - The property is inherited.
- Custom markers must be specified as CSS strings.
- The
autovalue allows the browser to choose an appropriate marker. - An empty string requests no visible hyphenation marker.
- The property does not independently create hyphenation opportunities.
- The
hyphensproperty controls manual and automatic hyphenation behavior. - The HTML
langattribute helps browsers select language-specific hyphenation rules. - Soft hyphens provide explicit optional word-breaking opportunities.
- The
hyphenate-limit-charsproperty can restrict eligible hyphenation positions. - Emergency wrapping is not the same as hyphenation.
- Custom characters should remain readable and appropriate for the content's language.
- Browser support and hyphenation dictionaries vary.
- Use custom hyphenation markers as a progressive enhancement rather than a requirement for readable text.
Browser Support
The CSS hyphenate-character property has limited availability across browsers. Support for custom hyphenation markers may vary, and automatic hyphenation depends on the language and available browser dictionaries.
For current compatibility information, visit Can I Use? and search for hyphenate-character.
Browsers that do not recognize the property ignore the declaration and use their default hyphenation marker behavior.
Specifications
The hyphenate-character property is defined in the CSS Text Module Level 4 specification.
CSS Text Module Level 4: hyphenate-character
The specification describes how the browser determines the character or string displayed when text breaks at a hyphenation opportunity.
For additional documentation and examples, consult MDN Web Docs.
