<div class="content">
  <div class="buttons">
  <button class="button" onclick="noneOne()">none</button> 
  <button class="button" onclick="underline()">underline</button>  
  <button class="button" onclick="overline()">overline</button> 
    <button class="button" onclick="lineThrough()">line-through</button> 
  </div>

<div id="text" style="font-size: 35px;">CSS text-decoration-line Property</div>
  
  <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;
}

.content {
  position: relative;
}

.buttons {
  left:-40%;
  position: absolute;
  top:0;
  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: absolute;
  font-weight: bold;
  font-size:15px;
  width: 100%;
  left:0;
  top:100px;
}

#text {
  font-family: arial;
}
function noneOne() {
 document.getElementById("text").style.textDecorationLine="none" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "text-decoration-line: none;") {
    x.innerHTML = "text-decoration-line: none;";
  } else {
    x.innerHTML = "text-decoration-line: none;";
  }
}

function underline() { document.getElementById("text").style.textDecorationLine="underline" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "text-decoration-line: underline;") {
    x.innerHTML = "text-decoration-line: underline;";
  } else {
    x.innerHTML = "text-decoration-line: underline;";
  }
}

function overline() { document.getElementById("text").style.textDecorationLine="overline" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "text-decoration-line: overline;") {
    x.innerHTML = "text-decoration-line: overline;";
  } else {
    x.innerHTML = "text-decoration-line: overline;";
  }
}

function lineThrough() { document.getElementById("text").style.textDecorationLine="line-through" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "text-decoration-line: line-through;") {
    x.innerHTML = "text-decoration-line: line-through;";
  } else {
    x.innerHTML = "text-decoration-line: line-through;";
  }
}
Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.