</> Code Corner

HTML · HTML Media · Lesson 49

HTML YouTube

Embed YouTube videos with an iframe.

The easiest way to play videos is to upload them to YouTube and embed them with an <iframe>.

  • Upload the video to YouTube and note its video id
  • Define an <iframe> with src pointing to https://www.youtube.com/embed/VIDEO_ID
  • Use width and height to set the size

Example

<iframe width="420" height="236" src="https://www.youtube.com/embed/tgbNymZ7vqY" title="YouTube video" allowfullscreen></iframe>

Options

Keep reading “HTML YouTube”

Sign up to read the full lesson (1 more parts), try every example in the live editor, and take the 5-question quiz.

Chat with us 👋