Some Issues about character line breaks in css

Source: Internet
Author: User

In css, word-break can solve this problem. Write a test page to take notes. css code: body {font-size: 14px;} p {border: solid 1px red; width: 200px ;} <body> <p class = "test"> English Chinese English Englis333hEnglishEnglishEnglish Chinese chinese characters 123 ewewee 123 running nglishEnglish </p> </body> The effect is as stated in the topic. The following Code adds a style css to the p Tag :. test {word-break: break-all;} You can find that all texts, whether Chinese or English, or numbers, can be automatically forcibly transferred at the end of the p tag of the package, there will be a problem. We will split the character string that is originally a combination to see the effect, and then look at the css code :. test {word-break: hyphenate;} This css may break the character segment of the package element and start line feed at the break point. Then read the css code :. test {word-break: keep-all;} breaks a line at spaces between all character segments and retains the integrity of all character segments. The broken package element word-break has some attributes: css code :. test {word-break: normal;}/* default line feed in the browser */if you do not need to maintain word integrity, break-all can solve the container-breaking problem, because there is no word with a length that exceeds the width of a container in actual application, hyphenate can solve the problem that words must be complete and cannot be broken through the container, in some scenarios, you can use a scroll bar or overflow: hidden to keep the UI complete.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.