Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vertically centered child element within header element on same line

Tags:

html

css

I'm trying to do something simple. I'm trying to have a header tag, that has a child tag with a smaller font size, that is centered vertically, within that header element. I'm not quite sure how to achieve this.

<h2>BIG TITLE: <span>subtitle</span></h2>
like image 973
KingKongFrog Avatar asked Jul 20 '26 06:07

KingKongFrog


1 Answers

Use vertical-align

h2 span{
  vertical-align: middle; /* you can also use px... */
  font-size: 10px;
}
<h2>BIG TITLE: <span>subtitle</span></h2>

or pick any other desired value from https://developer.mozilla.org/en/docs/Web/CSS/vertical-align

like image 51
Roko C. Buljan Avatar answered Jul 22 '26 19:07

Roko C. Buljan



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!