Home > Web Front-end > CSS Tutorial > Introduction to the specific usage of css word-break attribute

Introduction to the specific usage of css word-break attribute

黄舟
Release: 2017-06-20 10:56:17
Original
2196 people have browsed it

Various line breaks will occur when processing text in a web page. So under what circumstances do page elements perform line breaks? We can precisely control this line break through the word-break code.

Grammar:

word-break : normal | break-all | keep-all
Copy after login

Parameters:

normal: In accordance with the text rules of Asian and non-Asian languages, line breaks within words are allowed
break-all : This behavior is the same as normal in Asian languages. Breaks within any word of a line of non-Asian language text are also allowed. This value is suitable for Asian text that contains some non-Asian text
keep-all : Same as normal for all non-Asian languages. For Chinese, Korean, and Japanese, word breaks are not allowed. Suitable for non-Asian text that contains a small amount of Asian text

Description:

Sets or retrieves the intra-word wrapping behavior of the text within the object . Especially when multiple languages ​​appear.
For Chinese, break-all should be used.
The corresponding script feature is wordBreak. Please see other books I have written.

Example:

div {word-break : break-all; }
Copy after login

Application code. We determined the parameters for word-break within the test element.

p.test {word-break:hyphenate;}
Copy after login

In terms of browser support, word-break still meets the requirements very well. Most browsers support this code.

How to use word-break. Its default value is normal Its inheritance property is yes Its version is CSS3

java usage. object.style.wordBreak="keep-all"In this java statement, we give a different parameter value.

The syntax of the code.

word-break: normal|break-all|keep-all;
Copy after login

There are three different situations in this code. normal is the browser default. break-all is a line break within a word. keep-all is a half-width space or hyphen.

style process, we give two different ways for learners to compare. At the same time, we can also see that the definition of the outer frame is also enabled at the same time.

<style> 
p.test1
{
width:13em; 
border:2px solid #000000;
word-break:hyphenate;
}

p.test2
{
width:13em; 
border:2px solid red;
word-break:break-all;
}
</style>
Copy after login

The above is the detailed content of Introduction to the specific usage of css word-break attribute. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template