alt-text

Embedding YouTube Videos in Markdown

Markdown is an extremely popular way to create web content due to its ease of use, portability, and readability. Popular use cases for markdown include note taking, blogging and documentation.

Markdown can be written in a simple text editor, generally saved as a .md file. From there it must be converted into HTML to be displayed on the web. This is done automatically on sites like GitHub, and can be easily accomplished with online tools or any major programming language.

YouTube videos can be great additions to content, but are not directly supported in markdown. Below we discuss options for displaying YouTube videos directly in markdown content.

Embedded YouTube Videos with HTML

Many frameworks/sites/libraries like Wordpress, Medium, Jekyll, etc. support using HTML, making it possible to display YouTube videos with <iframe> HTML tags.

<iframe width="420" height="315"
src="https://www.youtube.com/embed/<VIDEO ID>">
</iframe> 

The snippet above shows an example that can be used to embed a YouTube video into markdown. Simply replace <VIDEO ID> with the actual YouTube video's ID. For example:

 <iframe width="420" height="315"
src="https://www.youtube.com/embed/_PPWWRV6gbA">
</iframe> 

Iframes can be further styled and sized with HTML attributes and/or CSS classes.

Visit the YouTube documentation for more details on video player options such as autoplay or beginning the video at a certain point.

Other Options

Unfortunately, embedding HTML tags in Markdown is not supported everywhere, notably on GitHub. When embedding YouTube videos in an iframe is not an option, it is possible to embed a clickable thumbnail which will take you to the video on YouTube.

[![](https://img.youtube.com/vi/_PPWWRV6gbA/hqdefault.jpg)](https://www.youtube.com/watch?v=_PPWWRV6gbA)

This example shows how to create a clickable thumbnail by nesting an markdown image inside of a markdown link.