Skip to content

Embed YouTube video in Mkdocs

This example is from https://jameshfisher.com/2017/08/30/how-do-i-make-a-full-width-iframe/

Embed YouTube video in Mkdocs

<div>
  <div style="position:relative;padding-top:56.25%;">
    <iframe src="https://www.youtube.com/embed/nckseQJ1Nlg" frameborder="0" allowfullscreen
      style="position:absolute;top:0;left:0;width:100%;height:100%;"></iframe>
  </div>
</div>

Per this discussion comment in squidfunk/mkdocs-material: if you do not need to maintain an aspect ratio, then the surrounding div elements can be dropped

If you don't need to maintain an aspect ratio, you can drop the surrounding divs mentioned in the article, but it's often desired.