First and foremost
Your premise is incorrect, your text does not fit in div
. Your choice of lyrics may have given this illusion, see a better example:
#papel {width: 150mm;height: 30mm;border:1px solid red}
#papel span{font-size: 19vw;border:1px solid green;font-family:Arial;}
<div id="papel">
<span>ÇÃj</span>
</div>
Changing the behavior of span
and div
An alternative is to leave the div of the size of the line (or the line of the size of the div), so that they are the same.
In addition, if you want greater control, better treat span
as a block.
#papel {width: 150mm;border:1px solid red}
#papel span{display:block;font-size: 19vw;border:1px solid green;font-family:Arial;}
<div id="papel">
<span>RES ÇÃj</span>
</div>
Setting height with line-height
If you want to ignore accents and letters that pass from baseline as left in the comment, you can hit the div line size:
#papel {width: 150mm;height:30mm;border:1px solid red;overflow:hidden}
#papel span{font-size: 19vw;border:1px solid green;font-family:Arial;line-height:30mm}
<div id="papel">
<span>RES ÇÃj</span>
</div>
If in the above example you do not want to cut the accents completely, take out overflow:hidden
.
#papel {width: 150mm;height:30mm;border:1px solid red}
#papel span{font-size: 19vw;border:1px solid green;font-family:Arial;line-height:30mm}
<div id="papel">
<span>RES ÇÃj</span>
</div>
Note that what is valid in these last two examples is exactly the line-height
, causing the font to align to the space it has, so what "leaking" (or what is cut) will not interfere in the spaces of the neighboring elements.
Note: I think the easiest thing is to simply specify the height of the font in millimeters, I do not know if it makes sense to use vw
for paper measurements.