CSS Property: word-wrap
[this page | pdf | back links]
The CSS (CSS3) word-wrap property allows long words
to be broken at line ends and to wrap onto the next line.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
break-word
|
Otherwise unbreakable
words can be broken
|
normal
|
(default value). Words
can only be broken at allowed break points
|
Default Value:
|
normal
|
JavaScript syntax:
|
e.g. object.style.wordWrap="break-word"
|
Inherited:
|
Yes
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
p {border: 2px solid red; width: 70px; background-color: yellow}
.x1 {word-wrap: break-word;}
</style>
</head>
<body>
Element with default property<br>
<p>comfortable chair</p>
Property set using HTML
<p class="x1">comfortable chair</span></p>
Property set using JavaScript
<p id="x2">comfortable chair</p>
<script>
document.getElementById("x2").style.wordWrap = "break-word";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyWordWrap() {
var x = document.createElement("DIV"); x.style.wordWrap = "break-word"; return (window.getComputedStyle(x, null).wordWrap == "break-word");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties