In HTML and CSS, how do I make japanese text break lines correctly?

前端 未结 5 906
时光说笑
时光说笑 2021-01-04 03:23

I\'m writting a simple paragraph in both English and Japanese, using only HTML and CSS. The English text breaks lines normally (when a word doesn\'t fit on a line anymore, i

5条回答
  •  攒了一身酷
    2021-01-04 04:06

    English separates words with spaces, Japanese doesn't.

    Whether characters in Japanese form a word or not depends on context. In many cases, looking for certain grammatical (Kana) particles could be used to separate words - but this wouldn't even be close to being reliable.

    Essentially, you'd need a Japanese dictionary / understanding of the language to identify where the words start and end - a browser won't know how to do this.

    Alternatively, if you know the start and end of the words, you could perhaps wrap each one in a span - then use CSS to ensure each span wraps to a new line as a whole when it doesn't fit.

提交回复
热议问题