Add a button to play or pause the video. We then set the height and width of the video to one hundred percent to cover the entire background.
The following is a code snippet to set a video as the background of the website in HTML5.
<video autoplay muted loop id = "myVideo"> <source src = "demo.mp4" type = "video/mp4"> Your browser does not support HTML5 video. </video>
The following is the pause video −
function display() { if (video.paused) { video.play(); btn.innerHTML = "Pause the video!"; } else { video.pause(); btn.innerHTML = "Play"; } }
The above is the detailed content of How do I add a video to the website background in HTML 5?. For more information, please follow other related articles on the PHP Chinese website!