I'm trying to understand what is relevant for the actual inner height of a button.
I would expect the two buttons below to have the same height of 32px, and in particular the same inner height of 20px.
These are the styles and markup:
<style>
button {
font-size: 16px;
line-height: 1.25;
padding: 5px;
border: 1px solid grey;
}
svg {
width: 20px;
height: 20px;
}
</style>
<button>Button with text</button>
<button>
<svg viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg">
<path d="..."></path>
</svg>
</button>
https://jsfiddle.net/6sxb4zof/1/
The text-only button behaves as expected: It has an actual inner height of 20px equal to its line-height.
But if I replace that text with a 20px <svg>
, suddenly the inner height is 25px.
What is going on? How does the rendering logic work here?