- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How can I add video to site background in HTML 5?
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. </video>
The following is to pause the video −
function display() { if (video.paused) { video.play(); btn.innerHTML = "Pause the video!"; } else { video.pause(); btn.innerHTML = "Play"; } }
Advertisements