<div class="content">
  <div class="buttons">
  <button class="button" onclick="normal()">normal</button> 
  <button class="button" onclick="one()">1</button>  
  <button class="button" onclick="two()">1.8</button> 
    <button class="button" onclick="three()">25px</button> 
    <button class="button" onclick="four()">150%</button>
  </div>

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

.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: 150px;
  left:-200px;
  top:0;
}

#text {
  font-family: arial;
  position: absolute;
  top:0;
}
function normal() {
 document.getElementById("text").style.lineHeight="normal" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "line-height: normal;") {
    x.innerHTML = "line-height: normal;";
  } else {
    x.innerHTML = "line-height: normal;";
  }
}

function one() {
 document.getElementById("text").style.lineHeight="1" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "line-height: 1;") {
    x.innerHTML = "line-height: 1;";
  } else {
    x.innerHTML = "line-height: 1;";
  }
}

function two() {
 document.getElementById("text").style.lineHeight="1.8" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "line-height: 1.8;") {
    x.innerHTML = "line-height: 1.8;";
  } else {
    x.innerHTML = "line-height: 1.8;";
  }
}

function three() {
 document.getElementById("text").style.lineHeight="25px" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "line-height: 25px;") {
    x.innerHTML = "line-height: 25px;";
  } else {
    x.innerHTML = "line-height: 25px;";
  }
}

function four() {
 document.getElementById("text").style.lineHeight="150%" 
  
  var x = document.getElementById("code");
  if (x.innerHTML === "line-height: 150%;") {
    x.innerHTML = "line-height: 150%;";
  } else {
    x.innerHTML = "line-height: 150%;";
  }
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.