๐ Introduction
The hyphens property in CSS controls how words are hyphenated when text wraps across multiple lines. Modern browsers can automatically insert hyphens (like thisโ) to improve readability, especially for narrow layouts, long words, and multilingual content. This is extremely useful in responsive design, articles, books, and typography-heavy websites. โจ
๐ฏ Why Use hyphens?
- Improves readability in narrow layouts ๐ฑ
- Allows cleaner word wrapping in long paragraphs ๐
- Helps avoid large empty spaces (โrivers of textโ) ๐๏ธ
- Supports multilingual hyphenation (English, German, French, etc.) ๐
โจ Syntax
Basic Syntax
selector {
hyphens: none | manual | auto;
}Note
lang="" attribute in HTML. Example: <html lang="en">๐งฉ Available Values
1. none (default)
No hyphenation. Words will only break if forced by other CSS (e.g., word-break).
none Example
p {
hyphens: none;
}2. manual โ๏ธ
Hyphenation occurs only where the author inserts soft hyphens (­ HTML entity).
manual Example
p {
hyphens: manual;
}Example text: hyยญphenยญaยญtion
3. auto ๐ค
The browser automatically inserts hyphens based on language rules. This creates the most natural and readable wrapping.
auto Example
article {
hyphens: auto;
}๐ฅ Practical Examples
1. Improve Text in Narrow Containers
Narrow Layout Example
.narrow-text {
width: 180px;
hyphens: auto;
overflow-wrap: break-word;
}2. Article Styling
Article Typography
article p {
hyphens: auto;
text-align: justify;
line-height: 1.7;
}3. Manual Hyphenation Example
Manual Hyphens
<p>Hy­phen­a­tion improves read­abil­ity.</p>๐ Comparison Table
| Value | Automatic? | Soft Hyphens? | Use Case |
|---|---|---|---|
| none | No | No | Default, no hyphens |
| manual | No | Yes | Precise control by author |
| auto | Yes | Optional | Articles, blogs, responsive layouts |
๐ผ๏ธ Visual Example
Further details can be found at: https://dummyimage.com/900x250/eeeeee/000000&text=hyphens+none+|+manual+|+auto
โ ๏ธ Important Notes
Note
lang="" in HTML.Note
hyphens: auto; + overflow-wrap: break-word;๐ Conclusion
The hyphens property is a powerful typography tool that makes long words wrap gracefully and improves readability across different screen sizes. Use auto for most cases, manual for precise control, andnone when you donโt want any hyphens. Mastering this will elevate the professionalism of your text-heavy layouts. ๐