๐Ÿ”ก CSS Tutorial: hyphens

๐Ÿ“Œ 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

Automatic hyphenation depends on the language set by thelang="" 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 (&shy; 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&shy;phen&shy;a&shy;tion improves read&shy;abil&shy;ity.</p>

๐Ÿ“Š Comparison Table

ValueAutomatic?Soft Hyphens?Use Case
noneNoNoDefault, no hyphens
manualNoYesPrecise control by author
autoYesOptionalArticles, blogs, responsive layouts

๐Ÿ–ผ๏ธ Visual Example

โš ๏ธ Important Notes

Note

Browser support: Hyphens work best in modern browsers. For full effect, always specify lang="" in HTML.

Note

For best results combine: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. ๐Ÿš€