This is the code:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> </head> <body> <ol class="meaning"> <li class="meaning-item">这是一个示例句子,其中长单词应该被连字符分隔 <ul class="sentences"> <li class="sentence">这是一个示例句子,其中长单词应该被连字符分隔</li> <li class="translation">这是一个示例句子,其中长单词应该被连字符分隔</li> </ul> </li> </ol> </body> </html> .meaning { list-style-type: none; counter-reset: item; font-size: calc(0.7em + 2.5vw); word-break: break-all; hyphens: auto; } .meaning > li { position: relative; } .meaning > li::before { content: counter(item); counter-increment: item; position: absolute; top: 0; text-align: center; margin-left: calc(-0.7em - 2.5vw); } .sentences { list-style-type: none; padding-left: 0; }
The words are wrapped the way I want them to be, but the hyphen itself ("-") is not showing up where the words wrap.
Additionally, I want to explicitly tell the browser that the text in is in English (en),
# The text in
1.) Don't use
word-break: break-all;
- it will break the word anywhere, regardless of hyphen rules.2.) Use the
lang
attribute in thehtml
tag combined withhyphens: auto;
to enable automatic hyphens.3.) You can use different
lang
attributes in any element that contains other languages - see below how I putlang="de"
Applies to the lastli
element.