How to embed YouTube video using object tag?

Tedxxxx picture Tedxxxx · Sep 21, 2017 · Viewed 7.1k times · Source

I am trying to include YouTube video by object tag in HTML:

<object width="500" height="500" data="https://www.youtube.com/watch?v=aqsL0QQaSP4"></object>

Currently, the video doesn't display. I searched on W3Schools, they have similar code with a different URL and it works:

<object width="420" height="315"
data="https://www.youtube.com/v/XGSy3_Czz8k">
</object> 

What kind of URL can I use for the object data attribute?

Answer

Sam Gurdus picture Sam Gurdus · Sep 21, 2017

Figured it out. You need to add a "v/" to the end of youtube.com. Basically, the new video link that you embed is https://www.youtube.com/v/watch?v=aqsL0QQaSP4

<object width="420" height="315"
data="https://www.youtube.com/v/watch?v=aqsL0QQaSP4">
</object>