I'm trying to make a layout as "pixel perfect" as possible, but I've always come across this problem, using large fonts, there is a space above and below the font, like a padding / margin. I searched the subject, trying to relate to line-height, but to no avail. Does anyone have any explanation of how to get as close to the font size?
From what I saw the "way" is to use the negative line-height and try to adjust, however each font would have a different negative line-height. They also suggested that I look for more about " vertical rhythm ", " half-leading ",
Here's an example to illustrate the case better:
*{
box-sizing:border-box;
margin:0;
padding:0;
font-size:16px;
}
body{
font-family: 'Roboto', sans-serif;
}
h1{
outline:1px solid red;
font-size:120px;
vertical-align:text-top;
line-height:normal;
}
h2{
outline:1px solid blue;
font-size:90px;
margin-top:10px;
}
h4{
font-size:16px;
line-height:normal;
outline:1px solid green;
/*line height = 24px;*/
/* 16 * 1.5 = 24px; */
}
<link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet">
<h1>Font h1</h1>
<h2>Font h2</h2>
<h3>Font h3</h3>
<div class="wrapper">
<h4>Font h4</h4>
</div>