Code for Adding a Video / YouTube Video in HTML Website Page

0

HTML5 Video Code

Before HTML5, a video could only be played in a browser with a plug-in (like flash).

The HTML5 <video> element specifies a standard way to embed a video in a web page.

HTML <video> Tag

The controls attribute adds video controls, like play, pause, and volume.

<video width="640" height="360" controls>
    <source src="video.mp4" type="video/mp4">
    <source src="video.ogg" type="video/ogg">
    <source src="video.webm" type="video/webm">
    Your browser does not support the video tag.
</video>

HTML <video> Autoplay Attribute

To start a video automatically use the autoplay attribute.

<video width="640" height="360" autoplay>
    <source src="video.mp4" type="video/mp4">
    <source src="video.ogg" type="video/ogg">
    <source src="video.webm" type="video/webm">
    Your browser does not support the video tag.
</video>

HTML Embed YouTube Videos

Adding/Embedding a YouTube Video in HTML Webpage.

<iframe width="640" height="360" src="https://www.youtube.com/embed/abcdefghij">
</iframe>

YouTube Autoplay – https://www.youtube.com/embed/abcdefghij?autoplay=1

YouTube Playlist – https://www.youtube.com/embed/abcdefghij?playlist=abcdefghij

YouTube Loop – https://www.youtube.com/embed/abcdefghij?playlist=abcdefghij&loop=1

YouTube Controls – https://www.youtube.com/embed/abcdefghij?controls=0