How can I add video to site background in HTML 5?

HTMLJavascriptProgramming Scripts

Add a button to play or pause the video. Then we have styled the video to a hundred percentage height and width so that it covers the entire background.

The following is the code snippet to set video as a site background in HTML5.

<video autoplay muted loop id = "myVideo">
   <source src = "demo.mp4" type = "video/mp4">
   Your browser does not support HTML5 video.

The following is to pause the video −

function display() {
   if (video.paused) {;
      btn.innerHTML = "Pause the video!";
   } else {
      btn.innerHTML = "Play";
Updated on 24-Jun-2020 13:58:52