3

The browser support for hyphens: auto is still a bit lacking, even for English, but I would like to provide it already to my visitors using Firefox. If the browser does not support it, however, the gaps in the justified text are unseemly wide, and I would rather fall back on flush left alignment.

This is essentially what the CSS code looks like.

p {
    text-align: justify;
    -webkit-hyphens: auto;
    -moz-hyphens: auto;
    hyphens: auto;
}

I’m aware of JavaScript libraries like Hyphenator.js that provide hyphenation for a range of browsers, but is there maybe a pure CSS solution for my simpler use case? I’ve come to think of hyphenation as less than essential on the web, unfortunately, and don’t want to embed a JavaScript library if there is a simpler fallback solution. Thanks!

4

1 回答 1

2

新的 @supports 属性可以做到这一点,但也不是所有浏览器都支持。如果您愿意接受这一限制,您可以在此处查看 Mozilla 文档: @supports

于 2014-05-25T19:51:11.617 回答