Here is an alternative approach without using line height:
button {
height: 40px;
display: table;
}
button>span {
display: table-cell;
text-align: center;
vertical-align: middle;
}
button.one {
font-family: "Helvetica Neue";
font-size: 30px;
}
button.two {
font-family: sans-serif;
font-size: 18px;
}
button.three {
font-family: Helvetica;
font-size: 18px;
}
button.four {
font-family: Arial;
font-size: 20px;
}
button.five {
font-family: Times New Roman;
font-size: 30px;
}
<button class="one"><span>text</span></button>
<br>
<br>
<button class="two"><span>text</span></button>
<br>
<br>
<button class="three"><span>text</span></button>
<br>
<br>
<button class="four"><span>text</span></button>
<br>
<br>
<button class="five"><span>text</span></button>
If the text size
exceeds the height of the button, you will encounter a failed result due to the button's fixed height. This should be evident.