<div class="content">
  <div class="buttons">
  <button class="button" onclick="normalOne()">normal</button> 
  <button class="button" onclick="breakWord()">break-word</button> 
  </div>

  <div id="text" style="font-size: 35px;">CSSword-wrapProperty.</div>
</br>
  <div class="col"><h2>CSS Code:</h2><p id="code">CSS code</p>
</div>
</div>
body {
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.content {
  position: relative;
}

.buttons {
  position: relative;
  left:-200px;
  z-index:1;
}

button {
  background-color: #333;
  color: white;
  border: none;
  display: block;
  padding:5px;
  width: 100px;
  margin:5px;
  transition: .2s;
  font-weight: bold;
}

button:hover {
  background-color: white;
  color: #333;
}

.col {
  position: relative;
  font-weight: bold;
  font-size:15px;
  width: 200px;
  left:-200px;
  top:0;
}

#text {
  font-family: arial;
  position: absolute;
  top:0;
  left:-45%;
  width:180px;
  background-color: #bde0fe;
}
function normalOne() {
 document.getElementById("text").style.wordWrap="normal"  
  
  var x = document.getElementById("code");
  if (x.innerHTML === "word-wrap: normal;") {
    x.innerHTML = "word-wrap: normal;";
  } else {
    x.innerHTML = "word-wrap: normal;";
  }
}

function breakWord() {
 document.getElementById("text").style.wordWrap="break-word"  
  
  var x = document.getElementById("code");
  if (x.innerHTML === "word-wrap: break-word;") {
    x.innerHTML = "word-wrap: break-word;";
  } else {
    x.innerHTML = "word-wrap: break-word;";
  }
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.