wordWrap Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:wordWrap

Description

The wordWrap property gets and sets how long words can be broken and wrapped onto the next line.

Property Values

Value Description
normal Break words only at allowed break points
break-word break the unbreakable words
initialSets this property to its default value.
inheritInherits this property from its parent element.

Technical Details

Item Value
Default Value: normal
Return Value: A String, representing the word-wrap property of an element
CSS VersionCSS3

Allow long words to be able to break and wrap onto the next line:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {/* w ww  . j  av a  2 s. c  om*/
    width: 150px;
    height: 100px;
    background-color: lightblue;
    border: 1px solid black;
}
</style>
</head>
<body>

<div id="myDIV">thisthisthisthisthsithsithsithsithsi</div>

<button onclick="myFunction()">Test</button>

<script>
function myFunction() {
    document.getElementById("myDIV").style.wordWrap = "break-word";
}
</script>

</body>
</html>

Related Tutorials