ak.
ak.

Reputation: 3449

SVG image to match font size

I have a an SVG logo image. I would like to use it like so:

<h1>
  <img src="img/logo.svg" onerror="img/logo.png"></img>
  <span>Some header goes here</span>
</h1>

How can I ensure that the image always matches line-height of the header text in the <span>? Are there better approaches to have a logo in front of the header?

Upvotes: 2

Views: 2808

Answers (1)

Paul LeBeau
Paul LeBeau

Reputation: 101918

You could do something like:

<img src="img/logo.svg" width="1em" height="1em"/>

and make sure your SVG has a suitable viewBox.

Upvotes: 2

Related Questions