The CSS `word-wrap` property is a powerful tool for controlling how text wraps within its container. However, it doesn't always behave as expected with hyphenated words. This is where the `hyphens` property comes into play, offering more control over hyphenation. Let's delve into the `hyphens` property and understand how it interacts with `word-wrap`.
Understanding CSS Hyphenation
In typography, hyphenation is the process of breaking words at the end of a line and adding a hyphen to indicate the break. This is particularly useful in long texts to prevent excessive line length and improve readability. In CSS, the `hyphens` property allows us to control this behavior.
Values of the `hyphens` Property
- none: No automatic hyphenation. This is the default value.
- auto: The browser automatically hyphenates words where appropriate.
- manual: The browser only hyphenates words where a manual hyphen has been specified using the `` character.
Now, let's see how `hyphens` interacts with `word-wrap`.

The Interaction Between `word-wrap` and `hyphens`
The `word-wrap` property controls whether or not words should be broken across lines. It has two values: `normal` and `break-word`.
Using `word-wrap: normal` with `hyphens`
When `word-wrap` is set to `normal`, long words will not be broken across lines unless there's a soft hyphen (``) or a hyphen character (`-`) in the word. If you set `hyphens: auto`, the browser will automatically insert soft hyphens where appropriate, allowing long words to be broken.
Using `word-wrap: break-word` with `hyphens`
When `word-wrap` is set to `break-word`, long words will be broken across lines even if there are no hyphens. However, using `hyphens: auto` can still be beneficial as it ensures that words are broken at appropriate points, rather than simply being cut in half.

Browser Support
Support for the `hyphens` property is quite good, with all modern browsers (including IE11 and Edge) supporting it. However, support for automatic hyphenation can vary between browsers. It's always a good idea to test your designs in multiple browsers to ensure consistent behavior.
Best Practices
While `hyphens` can greatly improve the readability of long texts, it's not always necessary. For short texts or headings, it might be more appropriate to use `word-wrap: break-word` without `hyphens`. Always consider the context and the user experience when deciding whether to use `hyphens`.
Examples
| CSS | Result |
|---|---|
p {
width: 150px;
hyphens: auto;
}
|
Long words will be automatically hyphenated and wrapped. |
p {
width: 150px;
word-wrap: break-word;
}
|
Long words will be broken at any point, without hyphenation. |
p {
width: 150px;
word-wrap: break-word;
hyphens: auto;
}
|
Long words will be broken at appropriate points, with automatic hyphenation. |
In conclusion, the `hyphens` property is a powerful tool for controlling hyphenation in CSS. When used in conjunction with `word-wrap`, it can greatly improve the readability of long texts. However, it's important to understand how these properties interact and to use them judiciously to ensure the best user experience.























