Search code examples
cssgithubmarkdown

How to link an image in markdown and also resize the image?


I've been trying to link an image for my GitHub's project readme, and used this syntax to link the image:

[![alt text](https://link-to-my-pic.png)](https://www.youtube.com/youtube-id)

And it works. But, I want to resize my image. Somehow, I can't manage to resize it and still make it linkable- can someone please help?

Thanks!


Solution

  • Markdown does not allow for defining the width on an image. And Markdown formatting syntax is not processed within block-level HTML tags.

    So, you'll need to use a regular <a> tag with <img> tag, with a width attribute.

    <a href="https://www.youtube.com/youtube-id">
      <img src="https://placehold.it/350x350" width="200" />
    </a>