Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to set line breaking rules for non-CJK scripts in JavaScript?
Use the wordbreak property in JavaScript to set line breaking rules for non-CJK scripts. The following are CJK scripts: C for Chinese, J for Japanese, K for Korean.
Example
You can try to run the following code to learn how to implement wordbreak property −
<!DOCTYPE html>
<html>
<head>
<style>
#box {
width: 150px;
height: 120px;
background-color: lightblue;
border: 1px solid black;
}
</style>
</head>
<body>
<button onclick = "display()">Set</button>
<div id = "box">
This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.This is Demo Text.
</div>
<script>
function display() {
document.getElementById("box").style.wordBreak = "break-all";
}
</script>
</body>
</html>Advertisements