How is it using line-height ?
#box{ display:block; width:100%; height:200px; background-color:#ccc; } #text{ text-align:center; font-size:48px; line-height:30px; }
<div id="text">TEXT<em>pgjiq</em></div> <div id="box"></div>
The difficulty is that the height of the font is not determined, say, by the height of the capital letter T - it also includes ascents and descenders.
It is not possible to make CSS aware of the amount of space occupied by the ascending and descending mechanisms. Pushing pixel pixels is the best choice.
If you are worried that this is stored on different screens, and also for zooming in and out, this should be good: browsers very well maintain the proportions between the dimensions.
However, the only way to be 100% sure is to use an image or SVG.
source share