I need to vertically align a text in center inside a div. I have found many of way, but none of them respects exact content of the text - I am talking about small graphical parts below text line - letter e.g. "ygq" etc., which is missing when e.g. capital letters are used "YGQ", but it's still counted when text is displayed. I tried:
.button {
height: 20px;
line-height: 20px;
}
<div class="button">My text</div>
<div class="button">MY TEXT</div>
and the other way
.button {
height: 20px;
display: flex;
align-items: center;
}
<div class="button"><p>My text</p></div>
<div class="button"><p>MY TEXT</p></div>
I use padding attribute, when I am sure, no graphics below the line will be presented. Is there a way, how to align text generally based on its exact content?
Question How do I vertically center text with CSS? doesn't answer this as the solution is based on "line-height" which still takes count graphics below line as I mentioned in my question.