<div class="content">
  <div class="buttons">
  <button class="button" onclick="solid()">solid</button> 
  <button class="button" onclick="double()">double</button>  
  <button class="button" onclick="dotted()">dotted</button> 
    <button class="button" onclick="dashed()">dashed</button> 
    <button class="button" onclick="wavy()">wavy</button>
  </div>

<div id="text" style="font-size: 35px;">CSS text-decoration-style 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;
  text-decoration-line: underline;
}
function solid() {
 document.getElementById("text").style.textDecorationStyle="solid" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "text-decoration-style: solid;") {
    x.innerHTML = "text-decoration-style: solid;";
  } else {
    x.innerHTML = "text-decoration-style: solid;";
  }
}

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

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

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

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

Run Pen

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.