Update: I am seeking advice on how to align text to a baseline using different font sizes within a div
. Despite my efforts, I have not found a satisfactory solution online. It seems impossible to achieve without the use of a Javascript framework or css preprocessor. This is perplexing considering the known proportion of the font below the baseline.
In the provided code snippet below, changing the font size of .text2 to 22px causes the two text groups to no longer align at the baseline (the bottom of the 'h'). However, reverting it back to 32 px results in proper alignment. Since both fonts are in Arial and the descenders of the 'j' should be proportionate, any insights into why they do not align?
CSS:
.bottomalign
{
position: absolute;
float: left;
bottom: -.24em;
}
.container
{
position: relative;
height: 50px;
overflow: visible;
}
div
{
font-family: arial;
}
.text1
{
font-size: 16px;
}
.text2
{
font-size: 32px;
margin-left: 2px;
color: green;
}
HTML:
<div class="container">
<div class="bottomalign text1">jh</div>
<div class="bottomalign text2">jh</div>
</div>