1

My code:

<iframe height="420" width="315" src="https://www.youtube.com/watch?v=ddR9g- 
YzE8g" frameborder="0" allowfullscreen></iframe>

Problem is, video is not being displayed as shown in the codepen

The codepen: https://codepen.io/don0ts/pen/gjYJvq

Frank Puffer
  • 8,135
  • 2
  • 20
  • 45
Gustavo Rios
  • 71
  • 1
  • 6

3 Answers3

3

He you should use "/embed" along with the youtube link. A correct way of doing this should be :

<iframe width="420" height="315"
src="https://www.youtube.com/embed/tgbNymZ7vqY?autoplay=1">
</iframe>
Ojasvi Bhargava
  • 312
  • 1
  • 2
  • 10
0

Check the dev tools (usually with F12) It shows this:

Refused to display 'https://www.youtube.com/watch?v=ddR9g-YzE8g' in a frame because it set 'X-Frame-Options' to 'sameorigin'.

See: link

<iframe width="560" height="315" src="https://www.youtube.com/embed/ddR9g-YzE8g" frameborder="0" allow="autoplay; encrypted-media" allowfullscreen></iframe>
Nex
  • 25
  • 5
0

You should actually write this:

<iframe frameborder="0" height="190" src="https://www.youtube.com/embed/ddR9gYzE8g" width="100%"></iframe>