I want to have is the text "$29" that is in big text and one colour, and after that the text, "per month" in a smaller font different colour but is aligned vertically so it appears to be in the middle of the "$29". But nothing I tried worked. I have:
Hoping to get the text per month centered to the "$29" text.
.per {
color: hsl(71, 73%, 54%);
margin: auto;
text-align: center;
}
.whiteMoney {
color: red;
font-size: 20pt;
font-weight: 700;
vertical-align: center;
}
<p>
<span class="whiteMoney">$29</span>
<span class="per">per month<span>
</p>
2
Answers
One nice, modern way to do this is with
flex
layout:In case I’ve misunderstood and you want the items side by side but their middles to align, you could try this instead:
You could add some bottom padding to
.per
if you don’t like the visual effect, saypadding-bottom: 3px
.set vertical-align:middle, center doesn’t make sense for property vertical-align.